I am wanting to get rid of setting a ModelDoc2 Object along with SelectionManager and FeatureManager objects in my code where i would substitute the following
Current Method i use to write code
Dim ModDoc as ModelDoc2 = ISwapp.iactivedoc2
If Isnothing(ModDoc) = false then
Dim SelMgr as SelectionManager = ModDoc.ISelectionManager
Dim FeatMgr as FeatureManager = ModDoc.FeatureManager
Dim SKMgr as SketchManager = ModDoc.SketchManager
SelMgr.SuspendSelectionList()
DO SOMETHING
SelMgr.ResumeSelectionList()
End If
The way i would like to do it is as follows. I know that not setting these to a memory location will not let me access these if the active document changes which is fine as i am always using the active document. I am trying to avoid having to clean up my com objects after functions.
Let me know your thoughts.
If IsNothing(Iswapp.IactiveDoc2) = false then
If IsNothing(ISwapp.IActiveDoc2.ISelectionManager) = false and isnothing(ISwApp.IActiveDoc2.FeatureManager) = false and isnothing(ISwApp.IActiveDoc2.SketchManager) = false then
iSwApp.IActiveDoc2.ISelectionManager.SuspendSelectionList()
DO SOMETHING
iSwApp.IActiveDoc2.ISelectionManager.ResumeSelectionList()
end if
SolidworksApi macros