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<br>Dim swModel As Object<br>Dim feature As Object<br>Dim folder As Object<br>Dim swFeatMgrbAs Object<br>Sub main()<p>Set swApp = Application.SldWorks</p>Set swModel = swApp.ActiveDoc<br>Set feature = swModel.FirstFeature<br>Set swFeatMgr = swModel.FeatureManager<br>While Not feature Is Nothing<br> If feature.GetTypeName2 = "SolidBodyFolder" Then<br> Debug.Print feature.Name & " " & feature.GetTypeName2<br> Set folder = feature.GetSpecificFeature2<br> If Not folder Is Nothing Then<br> If folder.UpdateCutList Then<br> Debug.Print " " & feature.Name & " Updated"<br> End If<br> End If<br> End If<br> Set feature = feature.GetNextFeature<br>Wend<br>swFeatMgr.UpdateFeatureTree<br>Debug.Print "Getting Cut-List data"<br>Set feature = swModel.FirstFeature<br>While Not feature Is Nothing<br> If feature.GetTypeName2 = "CutListFolder" Then<br> Debug.Print feature.Name & " " & feature.GetTypeName2<br> Set folder = feature.GetSpecificFeature2<br> If Not folder Is Nothing Then<br> Dim CustomPropMgr As Object<br> Dim vCustomPropNames As Variant<br> Dim PropTypes As Variant<br> Dim PropValues As Variant<br> <br> Dim i As Long<br> Dim textexp As String<br> Dim texteval As String<br> Dim prop As String<br> Dim stat As Boolean<br> Set CustomPropMgr = feature.CustomPropertyManager<br> CustomPropMgr.GetAll vCustomPropNames, PropTypes, PropValues<br> For i = LBound(vCustomPropNames) To UBound(vCustomPropNames)<br> prop = vCustomPropNames(i)<br> Debug.Print " " & prop<br> CustomPropMgr.Get2 prop, textexp, texteval<br> Debug.Print " " & textexp<br> Debug.Print " " & texteval<br> Next i<br> End If<br> End If<br> Set feature = feature.GetNextFeature<br>Wend<br>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:
<p>Solid Bodies SolidBodyFolder<br> Solid Bodies Updated<br>Getting Cut-List data<br>Cut-List-Item7 CutListFolder<br> Bounding Box Length<br> "SW-Bounding Box Length@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Bounding Box Length@@@Cut-List-Item7@Part1.SLDPRT"<br> Bounding Box Width<br> "SW-Bounding Box Width@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Bounding Box Width@@@Cut-List-Item7@Part1.SLDPRT"<br> Sheet Metal Thickness<br> "SW-Sheet Metal Thickness@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Sheet Metal Thickness@@@Cut-List-Item7@Part1.SLDPRT"<br> Bounding Box Area<br> "SW-Bounding Box Area@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Bounding Box Area@@@Cut-List-Item7@Part1.SLDPRT"<br> Bounding Box Area-Blank<br> "SW-Bounding Box Area-Blank@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Bounding Box Area-Blank@@@Cut-List-Item7@Part1.SLDPRT"<br> Cutting Length-Outer<br> "SW-Cutting Length-Outer@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Cutting Length-Outer@@@Cut-List-Item7@Part1.SLDPRT"<br> Cutting Length-Inner<br> "SW-Cutting Length-Inner@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Cutting Length-Inner@@@Cut-List-Item7@Part1.SLDPRT"<br> Cut Outs<br> "SW-Cut Outs@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Cut Outs@@@Cut-List-Item7@Part1.SLDPRT"<br> Bends<br> "SW-Bends@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Bends@@@Cut-List-Item7@Part1.SLDPRT"<br> Bend Allowance<br> "SW-Bend Allowance@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Bend Allowance@@@Cut-List-Item7@Part1.SLDPRT"<br> Material<br> "Material@@@Cut-List-Item7@Part1.SLDPRT"<br> Material <not specified><br> Mass<br> "SW-Mass@@@Cut-List-Item7@Part1.SLDPRT"<br> 170.63<br> Description<br> Sheet<br> Sheet<br> Bend Radius<br> "SW-Bend Radius@@@Cut-List-Item7@Part1.SLDPRT"<br> "SW-Bend Radius@@@Cut-List-Item7@Part1.SLDPRT"<br> Surface Treatment<br> "SW-Surface Treatment@@@Cut-List-Item7@Part1.SLDPRT"<br> Finish <not specified></p>
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