How can I get a profile Size for Weldment structural member via API?

Hello!

I have a Weldment assembly - lots of  structural members in the tree Named Structural Member 1/2/3 etc....

When you go to Edit Structural Member you can change a weldment profile:

Do you guys know how to get the structural member Size (circled above) via API?

Any ideas or links to similar topics very appreciated.

Thank you.

SolidworksApi macros
Answers 3
DG
DG 2016-05-17 Best Answer

Check WeldmentProfilePath in API help files.

SF
SF 2016-05-17

Thanks,

Deepak, its not very clear to me how to get to that property. I can get a structural body name using the swBody feature (im using drawings to get all bodies)

Any help here?

Thank you.

           Dim swWeldFeat As Feature

         Dim swWeldFeatData As StructuralMemberFeatureData

        swModel = swApp.ActiveDoc

        swSelMgr = swModel.SelectionManager

        swView = swSelMgr.GetSelectedObject6(1, -1)

        nbrBodies = swView.GetBodiesCount

        arrBody = swView.Bodies

        For i = 0 To UBound(arrBody)

            swBody = arrBody(i)

            swSelData = swSelMgr.CreateSelectData

            swSelData.View = swView

            bool = swBody.Select2(False, swSelData)

            objType = swSelMgr.GetSelectedObjectType3(1, -1)

            ' adding Descriptions on to the combo box

            If Mid(swBody.GetSelectionId, 1, 17) = "Structural Member" Then

                ComboBox1.Items.Add(swBody.Name)

           End If

' so here I`d like to show the Profile SIZE but dont know how to get to it.

   Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

        swModel.ClearSelection2(True)

        boolstatus = swModel.Extension.SelectByID2(ComboBox1.SelectedItem, "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

        swWeldFeat = swSelMgr.GetSelectedObject6(1, 0)

        swWeldFeatData = swWeldFeat.GetDefinition ' ERROR Additional information: Object reference not set to an instance of an object.

        MessageBox.Show("Path : " & swWeldFeatData.WeldmentProfilePath)

     end sub

To be able to achieve that I have to switch to the weldment model (I guess I could do that but still curious if I can use drawings reference.)

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

        swModel.ClearSelection2(True)

        swApp.ActivateDoc2("210363 10 Weldment", False, longstatus)

        swModel = swApp.ActiveDoc

        swSelMgr = swModel.SelectionManager

        boolstatus = swModel.Extension.SelectByID2(ComboBox1.SelectedItem, "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

        swWeldFeat = swSelMgr.GetSelectedObject6(1, 0)

        swWeldFeatData = swWeldFeat.GetDefinition

        MessageBox.Show("Path : " & swWeldFeatData.WeldmentProfilePath)

DG
DG 2016-05-21

Sorry for a late reply. I can see that you've achieved the result (and that is when you're in model).

I'll have to check as how to get the information hen in drawing mode.