5 Replies Latest reply on Jul 7, 2017 6:09 PM by Amen Allah Jlili

    Bounding Box of Temporary body problem

    roberto gennari

      I created a temporary body and I wanted to calculate the bounding box of this solid using tessellation



      ProcessBodies(X_max, X_min, Y_max, Y_min, Z_max, Z_min, temporaryBody)









      I saw that once the temporary body is created, the calculation will not work if the body is not displayed with Dispay3,

      because X_max, X_min, Y_max, Y_min, Z_max, Z_min return "Infinite"
      Am I doing something wrong?

      Can I run this calculation even if the temporary body is not displayed?




        • Re: Bounding Box of Temporary body problem
          Andreas Killer

          Well, if you have a Body object, why not use the GetBodyBox function?




          Sub Main()
            Dim swApp As SldWorks.SldWorks
            Dim swPart As SldWorks.PartDoc
            Dim swAll As SldWorks.EnumBodies2
            Dim swBody As SldWorks.Body2
            Dim Result, Msg
            Dim i As Long
            Set swApp = Application.SldWorks
            Set swPart = swApp.ActiveDoc
            'Enumerate all bodies
            Set swAll = swPart.EnumBodies3(swBodyType_e.swAllBodies, False)
            'Get the 1st one
            swAll.Next 1, swBody, 0
            'While found
            Do While Not swBody Is Nothing
              'Get the boundary
              Result = swBody.GetBodyBox
              Msg = ""
              For i = LBound(Result) To UBound(Result)
                Msg = Msg & Format(Result(i) * 1000, "0.000") & " "
              Debug.Print Msg
              'Get next
              swAll.Next 1, swBody, 0
          End Sub