Importing DXF files and manipulating with Mathematica

2

I have five DXF files with various geometric shapes.

TheyaresquareswithadifferentgeometricshapeineachDXFfile...

FourDXFfileshaveasquarewithadifferentgeometricshapeononeside,asshownabove.

( DXF1 , DXF2 , DXF3 , DXF4 , #

  • Is it possible to merge these 5 files?
  • Some files are in the wrong position to be mounted, can you rotate them?

  • Is it possible to create a code that can recognize these geometries and do some assembly like this? The animation is only illustrative. It was created just to make it easier to understand.

  •     
    asked by anonymous 22.12.2016 / 00:40

    1 answer

    1
    ReplaceList[MeshPrimitives[#, 2] & /@ meshes, {___,
        {a : Polygon[{___, ap : Repeated[_, {3}], ___}]}, ___,
        {b : Polygon[{___, bp : Repeated[_, {3}], ___}]}, ___} :>
       Module[{err, trans},
        {err, trans} = 
         Chop[FindGeometricTransform[{ap}, Reverse@{bp}, 
           TransformationClass -> "Rigid", Method -> "Linear"], 0.001];
        {Property[a \[DirectedEdge] b, "trans" -> trans],
          Property[b \[DirectedEdge] a, "trans" -> InverseFunction@trans]} /;
         err < 1 && 
          Quiet@Area[
             RegionIntersection[BoundaryDiscretizeRegion@a, 
              BoundaryDiscretizeRegion@TransformedRegion[b, trans]]] < 1]] //
     With[{g = Graph@Flatten@#},
       Graphics[{FaceForm[], EdgeForm@Thick, First@VertexList@g,
         GeometricTransformation[#,
            Composition @@ (PropertyValue[{g, DirectedEdge @@ #}, "trans"] & /@ 
               Partition[FindShortestPath[g, First@VertexList@g, #], 2, 1])] & /@
          Rest@VertexList@g}]] &
    

        
    22.12.2016 / 00:52