I am writing a macro to set a few properties of the cut list items.
Pre conditions : a few cut list items are selected.
Post conditions:
1. Boundary boxes are created.
2. Bounding Box Width and length are found
3. Description is set
<p>Option Explicit</p><p>Dim swApp As Object</p><p>Dim swModel As SldWorks.ModelDoc2</p><p>Dim swSelMgr As SldWorks.SelectionMgr</p><p>Dim swCustPropMgr As SldWorks.CustomPropertyManager</p><p>Dim swFeat As SldWorks.Feature</p><p>Dim selComp As Component2</p><p>Dim Part As Object</p><p>Dim boolstatus As Boolean</p><p>Dim longstatus As Long, longwarnings As Long</p><p>Dim i As Integer</p><p>Dim iCount As Integer</p><p>Dim bool As Boolean</p><p>Dim valout As String</p><p>Dim strValue(7) As String</p><p>Dim Counter As Integer</p><p></p><p></p><p>Sub main()</p><p></p><p></p><p> Set swApp = Application.SldWorks</p><p> Set swModel = swApp.ActiveDoc</p><p> Set swSelMgr = swModel.SelectionManager</p><p></p><p></p><p> iCount = swSelMgr.GetSelectedObjectCount2(-1)</p><p></p><p></p><p> For i = 0 To iCount - 1</p><p> Set selComp = swSelMgr.GetSelectedObjectsComponent4(i + 1, -1)</p><p> MsgBox (selComp.Name2)</p><p> bool = swModel.Extension.SelectByID2(selComp.Name2, "SUBWELDFOLDER", 0, 0, 0, False, 0, Nothing, 0)</p><p> </p><p> </p><p> swModel.Extension.Create3DBoundingBox</p><p> Counter = Counter + 1</p><p></p><p></p><p></p><p></p><p> Set swCustPropMgr = swFeat.CustomPropertyManager</p><p> swCustPropMgr.Get4 "Bounding Box Width", False, strValue(0), strValue(1)</p><p> swCustPropMgr.Get4 "Bounding Box Length", False, strValue(2), strValue(3)</p><p> swCustPropMgr.Set2 "Description", "Bar" & Counter</p><p> </p><p> </p><p> </p><p> If strValue(0) <= 3.18 And strValue(0) >= 3.13 Then</p><p> MsgBox (strValue(0))</p><p></p><p> End If</p><p> Next i</p><p>End Sub</p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p>SolidworksApi macros
