AnsweredAssumed Answered

Why only use Traverse Feature in Drawing.don't use GetSelectedObject5?

Question asked by Yong Ning on Aug 3, 2015
Latest reply on Aug 3, 2015 by Yong Ning



Why don't use SwSelMgr.GetSelectedObject5(1) → Result is Error


   Dim SwFeat as Feature

   Set SwFeat = SwSelMgr.GetSelectedObject5(1)→Result is Error.

dim SwSheet As Sheet

   Set SwSheet = SwSelMgr.GetSelectedObject5(1)→Result is True.


Code is


   Dim SwSelMgr As SelectionMgr

      Set SwSelMgr = SwModel.SelectionManager

   Dim SwFeat As Feature, SwSheet As Sheet

      Set SwFeat = SwSelMgr.GetSelectedObject5(1)

      Debug.Print SwSheet.GetName



Why Select Feature in Sheet of Drawing. can be use Traverse Feature.


code is



Private Sub l5()

   Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

      Set SwApp = Application.SldWorks

      Set SwModel = SwApp.ActiveDoc

      SwModel.ClearSelection2 True


   Dim SwFeat As Feature

      Set SwFeat = SwModel.FirstFeature

      Do While Not SwFeat Is Nothing

          If SwFeat.GetTypeName = "DrSheet" Then

              Debug.Print SwFeat.Name, SwFeat.GetTypeName

              SwFeat.Select True

          End If

          Set SwFeat = SwFeat.GetNextFeature




End Sub