To select the last created plane

To select by using SolidWorks API / Macro to select the last plane on the Feature Manager tree

  • Dim swApp As SldWorks.SldWorks
  • Dim swmodel As SldWorks.ModelDoc2
  • Dim swfeat As SldWorks.Feature
  • Dim var As Variant
  • Dim swfeatmgr As SldWorks.FeatureManager
  • Dim n As Integer
  • Dim plan As Variant
  • Dim swplan As SldWorks.Feature
  • Dim bool As Boolean
  • Sub main()
  • Set swApp = Application.SldWorks
  • Set swmodel = swApp.ActiveDoc
  • Set swfeatmgr = swmodel.FeatureManager
  • var = swfeatmgr.GetFeatures(False)
  • For i = 0 To UBound(var)
  • Set swfeat = var(i)
  • If swfeat.GetTypeName2 = "RefPlane" Then
  • n = i
  • Debug.Print swfeat.Name & "  " & swfeat.GetTypeName2
  • End If
  • Next
  • bool = var(n).Select2(False, 0)
  • End Sub

Comments

Popular posts from this blog

SolidWorks Macro to create DXF file from each configuration