Hello all,
I am trying to select the cutting list folder as parts of a larger macro and run the function to create the 3D bounding boxes. Exactly the way I have been doing it by hand.
Probably due to lack of sufficient knowledge I don't manage to select with the macro the cutlists folder
In the old Solidworks forum I found the following macro
https://forum.solidworks.com/thread/201686
The macro works after a few minor adjustments, but with the difference to the manual execution that the bounding box is inserted in all cutting list elements, even in the structural elements where it is not required.
When executed manually over the topmost cut list folder, the bounding box is added only to the elements that do not contain structural elements.
Does anyone have a tip for me on how to program the macro to achieve the same result as when executed manually.
by JSculley » Fri Dec 23, 2022 12:30 pm
Here's a minimal example that will put a bounding box around every cut list item that isn't a structural member.
Code: Select all
Dim swApp As SldWorks.SldWorks
Dim fMgr As FeatureManager
Dim mDoc As ModelDoc2
Dim mExt As ModelDocExtension
Dim fCount As Integer
Dim retval As Boolean
Sub main()
Set swApp = Application.SldWorks
Set mDoc = swApp.ActiveDoc
Set mExt = mDoc.Extension
Set fMgr = mDoc.FeatureManager
fCount = fMgr.GetFeatureCount(False)
Dim nextFeature As Feature
Dim featureObjectArray As Variant
featureObjectArray = fMgr.GetFeatures(False)
For i = 0 To fCount - 1
Set nextFeature = featureObjectArray(i)
If nextFeature.GetTypeName2() = "CutListFolder" Then
Dim folder As BodyFolder
Set folder = nextFeature.GetSpecificFeature2
If (folder.GetCutListType <> swCutListType_e.swWeldmentCutlist) Then
retval = nextFeature.Select2(False, -1)
mExt.Create3DBoundingBox
End If
End If
Next
End Sub
Go to full post
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.