I have two macros that i am trying to combine into one. One macro gets the properties of a selected cut-list-item. The other macro actually loops through cut-list-item folders without actually having to pre-select a folder. Down below in red you will see a line that i usually have set to "Set swCutlistItem = swSelMgr.GetSelectedObject6(1, 0)". But i am trying to do this by finding the first feature and looping through to the next feature and so on. But i am really not too for sure as to what i need to Set swCutlistItem to. Thanks for your time.
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swCutlistItem As SldWorks.Feature
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim names As Variant
Dim name As Variant
Dim textexp As String
Dim evalval As String
Dim propname As String
Dim propevalval As Variant
Sub Main()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set SelMgr = swDoc.SelectionManager
Set swFeature = swDoc.FirstFeature
Do While Not swFeature Is Nothing
If swFeature.GetTypeName = "CutListFolder" Then
CutListQty = swFeature.GetSpecificFeature2.GetBodyCount
If CutListQty > 0 Then
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swCutlistItem = instance.GetSpecificFeature2()
Set swCustPropMgr = swCutlistItem.CustomPropertyManager
Debug.Print "Custom Properties for Selected Weldment Cut-list Item"
Debug.Print "Number of custom properties = " + CStr(swCustPropMgr.Count)
Debug.Print "Name", "Text Expression", "Value", "Type"
names = swCustPropMgr.GetNames
For Each name In names
swCustPropMgr.Get2 name, textexp, evalval
Debug.Print name, textexp, evalval, swCustPropMgr.GetType(name)
propname = name
propevalval = evalval
If propname = "Sheet Metal Thickness" And propevalval = 0.313 Then
lRet = swCutlistItem.CustomPropertyManager.Add("PartNumber", "Text", "112bxx")
End If
Next name
'lRet = swFeature.CustomPropertyManager.Add("CutListQty", "Text", CutListQty)
End If
End If
Set swFeature = swFeature.GetNextFeature
Loop
End Sub
SolidworksApi macros