AnsweredAssumed Answered

Unable to select a sketch feature by selecting a view on the drawing

Question asked by Abilash V. on May 8, 2018
Latest reply on May 17, 2018 by Abilash V.

I am been trying to select  all the sketch in drawing and trying to show them all. but the selection never works.


Dim swApp As SldWorks.SldWorks
Dim swmodel As SldWorks.ModelDoc2
Dim selmgr As SldWorks.SelectionMgr
Dim swSelData As SldWorks.SelectData
Dim swview As SldWorks.View
Dim swdraw As SldWorks.ModelDoc2
Dim swfeat As SldWorks.Feature
Dim swfeatmgr As SldWorks.FeatureManager
Dim vfeat As Variant
Dim swassem As SldWorks.AssemblyDoc
Dim swcomp As SldWorks.Component2
Dim vcomp As Variant
Sub main()
Set swApp = Application.SldWorks
Set swmodel = swApp.ActiveDoc
Set swSelMgr = swmodel.SelectionManager
Set swview = swSelMgr.GetSelectedObject6(1, -1)
Set swSelData = swSelMgr.CreateSelectData
'Set swdraw = swview.RootDrawingComponent
Debug.Print swview.GetName2
Set swdraw = swview.ReferencedDocument
Set swfeatmgr = swdraw.FeatureManager
Debug.Print swdraw.GetTitle
vfeat = swfeatmgr.GetFeatures(False)
'For i = 0 To UBound(vfeat)
'Set swfeat = vfeat(i)
'Debug.Print swfeat.Name
Set swassem = swdraw
' swApp.ActivateDoc swdraw.GetTitle
Debug.Print swassem.GetComponentCount(False)
vcomp = swassem.GetComponents(False)
For i = 0 To UBound(vcomp)
Set swcomp = vcomp(i)
Set swfeat = swcomp.FirstFeature
  While Not swfeat Is Nothing
Debug.Print swfeat.GetTypeName2
swmodel.ClearSelection2 True
If swfeat.GetTypeName2 = "ProfileFeature" Then
Dim bool As Boolean
bool = swfeat.Select2(False, 0)
Debug.Print swfeat.Visible
End If
'swdraw.ClearSelection2 True
  Set swfeat = swfeat.GetNextFeature
End Sub



kindly help

Artem Taturevich  Christian Chu @