AnsweredAssumed Answered

Edit a sketch in a new virtual part

Question asked by Drew Miller on Dec 19, 2014
Latest reply on Dec 22, 2014 by Drew Miller

Hello-  using vba & sw2013.  Currently macro successfully inserts a new virtual part into an assembly in a selected face from a pmp selectionbox.    Need to be able to add some geometry to that blank new part- which contains "Sketch1", basically to create a rectangular sketch on sketch1.  I am unable to edit the virtual component Sketch1 feature.  Here's what I've got so far- have tried a couple ways to select and edit the sketch. 


' Create the part and insert it as a virtual component in the assembly

        Status = swAssy.InsertNewVirtualPart(swFeature, swComponent)  ' this works

        Status = swComponent.Select(False)


        Set swModelForEdit = swComponent.GetModelDoc2()  ' way to get modeldoc from a component object

        Set swConf = swModelForEdit.GetActiveConfiguration() ' gets the virtual part's active configuration

        Debug.Print swComponent.Name + " " + swConf.Name  'output the name and active config of the inserted part

         TraverseFeatures swComponent.FirstFeature  'must pass the component's first feature to begin traversing features, this outputs the feature names in the output window, works ok



        statInfo = swAssy.EditPart2(True, False, info)

        Set swEditModel = swAssy.GetEditTarget()

        Set swEditPart = swEditModel

'        Set swFeat = swEditPart.FeatureByName("Sketch1") '.FeatureByName("Sketch1")

'        Status = swFeat.Select2(False, -1)

        Status = swEditModel.Extension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)