3 Replies Latest reply on Jun 18, 2014 2:37 PM by Ryan Gerry

    Edit bounding box reference face/planes with macro?

    Ryan Gerry

      I have a macro that creates a bounding box for a pipe selected in the weldment cut list folder.  The default bounding box seems to be aligned with a global axis, however I need it to reference the face of the end of the pipe.  How do I select a features end face/plane and then use as a reference for a bounding box with VBA?

       

      Capture-Default Bounding Box.JPG

      Default Bounding Box Orientation

       

      Capture-Edit Bounding Box.JPG

      Oriented Bounding Box

       

       

      Using SW 2014 Service Pack 2

       

      Thanks!

        • Re: Edit bounding box reference face/planes with macro?
          Artem Taturevych

          Unfortunately you won't be able to just select the face and get the bounding box relatieve to it. You need to build the transformation matrix of this face to transform your box. Take a look at IMathUtility interface and math transforms.

          ______________________________________________

          Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

           

          IC3DSteel – New Steel Solution for SolidWorks

          LinkedIn - SolidWorks API Group

            • Re: Edit bounding box reference face/planes with macro?
              Ryan Gerry

              Artem,

               

              Thanks for the reply.  With the simple bounding box code I have now, if I select the weldment cut list folder that contains the pipe I am adding a bounding box to and the face I want to use as a reference, then run the macro, it inserts a bounding box with that face automatically as a reference. 

               

              Is there any way to select a face of a pipe automatically only having the cut list folder selected?

               

              Are there any links between the body feature and the cut list item that can be accessed within VBA?

            • Re: Edit bounding box reference face/planes with macro?
              Ryan Gerry

              Got it to work!  Using DoEvents, the macro is paused until the user makes a selection, then adds the subweldfolder to the same selection list before creating the bounding box.  The result is a bounding box with the selected face as a reference. 

               

               

               

               

              MsgBox "Select Face for Bounding Box Reference"

                     

              While swSelMgr.GetSelectedObjectCount < 1

              DoEvents

              swSelMgr.GetSelectedObject6 1, 0

              Wend

                                         

              'add cutlist folder to new selection list

              swModel.Extension.SelectByID2 swCutlistItem.Name, "SUBWELDFOLDER", 0, 0, 0, True, 0, Nothing, 0

               

              swModel.Extension.Create3DBoundingBox