Hello,
I am trying to update the Weldment Cut List of a part and after that to get all the properties.
I have created a new part with a new Sheet Metal object and haven't update the CutList in the Feature Manager.
Then I use this macro: (Sorry for the objects types, I have some problem with the type library):
Dim swApp As Object
Dim swModel As Object
Dim feature As Object
Dim folder As Object
Dim swFeatMgrbAs Object
Sub main()Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set feature = swModel.FirstFeature
Set swFeatMgr = swModel.FeatureManager
While Not feature Is Nothing
If feature.GetTypeName2 = "SolidBodyFolder" Then
Debug.Print feature.Name & " " & feature.GetTypeName2
Set folder = feature.GetSpecificFeature2
If Not folder Is Nothing Then
If folder.UpdateCutList Then
Debug.Print " " & feature.Name & " Updated"
End If
End If
End If
Set feature = feature.GetNextFeature
Wend
swFeatMgr.UpdateFeatureTree
Debug.Print "Getting Cut-List data"
Set feature = swModel.FirstFeature
While Not feature Is Nothing
If feature.GetTypeName2 = "CutListFolder" Then
Debug.Print feature.Name & " " & feature.GetTypeName2
Set folder = feature.GetSpecificFeature2
If Not folder Is Nothing Then
Dim CustomPropMgr As Object
Dim vCustomPropNames As Variant
Dim PropTypes As Variant
Dim PropValues As Variant
Dim i As Long
Dim textexp As String
Dim texteval As String
Dim prop As String
Dim stat As Boolean
Set CustomPropMgr = feature.CustomPropertyManager
CustomPropMgr.GetAll vCustomPropNames, PropTypes, PropValues
For i = LBound(vCustomPropNames) To UBound(vCustomPropNames)
prop = vCustomPropNames(i)
Debug.Print " " & prop
CustomPropMgr.Get2 prop, textexp, texteval
Debug.Print " " & textexp
Debug.Print " " & texteval
Next i
End If
End If
Set feature = feature.GetNextFeature
Wend
End Sub
The first While here is to update the CutList. Works fine.
After that, I get from the CutList only the expresions, not the resolved expression.
Sample of output:
Solid Bodies SolidBodyFolder
Solid Bodies Updated
Getting Cut-List data
Cut-List-Item7 CutListFolder
Bounding Box Length
"SW-Bounding Box Length@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Bounding Box Length@@@Cut-List-Item7@Part1.SLDPRT"
Bounding Box Width
"SW-Bounding Box Width@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Bounding Box Width@@@Cut-List-Item7@Part1.SLDPRT"
Sheet Metal Thickness
"SW-Sheet Metal Thickness@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Sheet Metal Thickness@@@Cut-List-Item7@Part1.SLDPRT"
Bounding Box Area
"SW-Bounding Box Area@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Bounding Box Area@@@Cut-List-Item7@Part1.SLDPRT"
Bounding Box Area-Blank
"SW-Bounding Box Area-Blank@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Bounding Box Area-Blank@@@Cut-List-Item7@Part1.SLDPRT"
Cutting Length-Outer
"SW-Cutting Length-Outer@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Cutting Length-Outer@@@Cut-List-Item7@Part1.SLDPRT"
Cutting Length-Inner
"SW-Cutting Length-Inner@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Cutting Length-Inner@@@Cut-List-Item7@Part1.SLDPRT"
Cut Outs
"SW-Cut Outs@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Cut Outs@@@Cut-List-Item7@Part1.SLDPRT"
Bends
"SW-Bends@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Bends@@@Cut-List-Item7@Part1.SLDPRT"
Bend Allowance
"SW-Bend Allowance@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Bend Allowance@@@Cut-List-Item7@Part1.SLDPRT"
Material
"Material@@@Cut-List-Item7@Part1.SLDPRT"
Material
Mass
"SW-Mass@@@Cut-List-Item7@Part1.SLDPRT"
170.63
Description
Sheet
Sheet
Bend Radius
"SW-Bend Radius@@@Cut-List-Item7@Part1.SLDPRT"
"SW-Bend Radius@@@Cut-List-Item7@Part1.SLDPRT"
Surface Treatment
"SW-Surface Treatment@@@Cut-List-Item7@Part1.SLDPRT"
Finish
You can see the not all of it are like that.
If go to SolidWorks and check the properties, I get all of them. After that running the macro again give me the correct values.
Do I need to refresh the ModelDoc2 after the cutlist update or something?
(Usually I work with VB.NET, I have made this macro as a sample)
Have a great weekend.
-Bnaya Livne
SolidworksApi macros