1 Reply Latest reply on May 18, 2016 4:04 AM by Jake Waight

    Macro: - Measure Solid Bodies

    Jake Waight

      I have a Macro that I use to measure parts within Assemblies / Sub-Assemblies (attached below)

      This works perfectly for gathering a cutting list for panels and quantity of stock parts,

      although this only works if each part only has one solid body.

       

      I'd like to know if there is a way of measuring each solid body with a part?

       

      I have tried saving bodies as split bodies/parts but this has not had an effect on the macro.

       

      This macro was written for me and I haven't the greatest knowledge of coding,

      But from what I can gather - it looks pretty close to be able to do what I would like.

       

      Any Thoughts would be greatly appreciated,

      Jake W

        • Re: Macro: - Measure Solid Bodies
          Jake Waight

          Right, I think I've found the piece code that determines Solid Bodies.

           

          Anyone have any idea to be able to read Multi-Body parts?

          <

          Sub ProcessBodies(vBodies As Variant, X_max As Double, X_min As Double, Y_max As Double, Y_min As Double, Z_max As Double, Z_min As Double)

              Dim swBody              As SldWorks.Body2

              Dim swFace              As SldWorks.Face2

              Dim vTessTriangles      As Variant

              Dim i                   As Long

             

              ' Probably empty if no reference surfaces

              If IsEmpty(vBodies) Then Exit Sub

              For i = 0 To UBound(vBodies)

                  Set swBody = vBodies(i)

                  Set swFace = swBody.GetFirstFace

                  While Not swFace Is Nothing

                      vTessTriangles = swFace.GetTessTriangles(True)

                      ProcessTessTriangles vTessTriangles, X_max, X_min, Y_max, Y_min, Z_max, Z_min

                      Set swFace = swFace.GetNextFace

                  Wend

              Next i

           

           

          End Sub