AnsweredAssumed Answered

Unable to insert sketch via API when document is not visible

Question asked by Stephane Bonnet on Aug 2, 2019
Latest reply on Aug 3, 2019 by Jacob Corder

Hi everyone,
Title says it all. The function modelDoc.SketchManager.InsertSketch works perfectly well when my document is opened with SwApp.DocumentVisible(True, swDocumentTypes_e.swDocPART) but, not when my document is opened with SwApp.DocumentVisible(False, swDocumentTypes_e.swDocPART). In that case no sketch is inserted and the call to SwModelDoc.SketchManager.ActiveSketch returns "Nothing". Code for clarity :


SwApp.DocumentVisible(False, swDocumentTypes_e.swDocPART)
SwModelDoc = SwApp.OpenDoc6(path, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, Nothing, Nothing, Nothing)

Dim swSketchMgr As SketchManager = SwModelDoc.SketchManager

SelectPlane() 'this part works fine
swSketchMgr.InsertSketch(True) 'this does nothing

'do stuff on my sketch