AnsweredAssumed Answered

macro to find out suppressed features are present in model tree or not

Question asked by Hari Hari on Jan 10, 2019

Hi,

 

I have written a macro to find out whether there are suppressed features present in model tree, if yes i need to send message to user that these many suppressed features in the model tree.. but the moment i run the code, solidworks hangs iteself and i need to kill it and restart it

 

following is the code

 

Dim swApp As SldWorks.SldWorks

Set swApp = Application.SldWorks

Dim swModel As SldWorks.ModelDoc2

Set swModel = swApp.ActiveDoc

Dim swfeature As SldWorks.Feature

Set swfeature = swModel.FirstFeature

 

 

Dim swsketch As SldWorks.Sketch

Dim bool As Boolean

 

 

 

 

Dim b As Integer

 

 

 

 

While Not swfeature Is Nothing

 

 

If swfeature.GetTypeName = "ProfileFeature" Then

'Set swsketch = swfeature.GetSpecificFeature

 

 

Set swfeature = swModel.FirstFeature

 

 

If swfeature.IsSuppressed2 Then

 

 

 

 

b = b + 1

 

 

End If

 

 

 

 

 

 

 

 

 

 

Set swfeature = swfeature.GetNextFeature

End If

 

 

 

 

Wend

 

 

 

 

 

 

If b = 0 Then

 

 

swApp.SendMsgToUser "no suppressed features"

 

 

ElseIf b > 0 Then

 

 

swApp.SendMsgToUser "Number of " & b & " " & " suppressed features "

End If

 

 

 

 

End Sub

 

 

Can someone tell me where am i doing wrong

Outcomes