AnsweredAssumed Answered

How to select Cutlist Item and create a 3D Bounding Box

Question asked by Raymond Yau on Mar 6, 2017
Latest reply on Mar 9, 2017 by Deepak Gupta

Hi All,

 

I've been programming a macro that would select the first feature in my Cut-list folder and then create a 3D Bounding Box for the selected item.

 

From what I've gathered from online resources, here is my (maybe 100th) attempt at the macro.

 

I'm struggling with the cut-list-item selection part. Some sources I viewed online demonstrates how to select Solid Bodies, but not cut-list item IDs. Perhaps I'm over complicating things?

 

Help much appreciated.

 

Sources used:

2016 SOLIDWORKS API Help - Create 3D Bounding Box for Cut List Item Example (VBA)

2015 SOLIDWORKS API Help - Get Names of Bodies in Multibody Part Example (VBA)

2016 SOLIDWORKS API Help - Get Weldment Cut List Feature and Annotations Example (VB.NET)

Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.ModelDoc2

Dim modDocExt As SldWorks.ModelDocExtension

Dim boolstatus As Boolean

Dim swfeat As Feature

Dim CutItem As String

 

Option Explicit

 

Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc

    Set modDocExt = Part.Extension

   

   

    ' Traverse FeatureManager design tree

    ' Get first feature in FeatureManager design tree

    swfeat = Part.FirstFeature

   

   

    'Get ID of first feature

    CutItem = swfeat.GetID

 

 

    ' Once body selected, create a bounding box

    boolstatus = modDocExt.SelectByID2(CutItem, "SUBWELDFOLDER", 0, 0, 0, False, 0, Nothing, 0)

    modDocExt.Create3DBoundingBox

End Sub

 

Outcomes