AnsweredAssumed Answered

WHY IT'S NOT CREATING PLANE

Question asked by Arlene Garfield on Nov 1, 2019
Latest reply on Nov 4, 2019 by Artem Taturevych

Why is this macro not creating a reference plane when items are preselected.   I have a simple model where I select the sketch point and a surface.  But no reference plane is created.  I gives me the message box after the end.  Debugger isn't alerting me to anything.

 

SELECTION

 

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swModelDocExt As Object

Dim Part As Object

Dim swFeatureManager As SldWorks.FeatureManager

Dim swFeature As SldWorks.Feature

Dim myRefPlane As Object

Dim swSelMgr As SldWorks.SelectionMgr

Dim swRefPlaneFeatureData As SldWorks.RefPlaneFeatureData

Dim fileerror As Long

Dim filewarning As Long

Dim boolstatus As Boolean

Dim planeType As Long

 

Sub main()

 

Set swApp = Application.SldWorks

swApp.OpenDoc6 "U:\TEST 600\TEST PART3.sldprt", swDocPART, swOpenDocOptions_Silent, "", fileerror, filewarning

Set swModel = swApp.ActiveDoc

Set swModelDocExt = swModel.Extension

Set swFeatureManager = swModel.FeatureManager

Set swSelMgr = swModel.SelectionManager

 

' Create a constraint-based reference plane

boolstatus = swModel.Extension.SelectByID2("", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)

boolstatus = swModel.Extension.SelectByID2("", "FACE", 0, 0, 0, True, 1, Nothing, 0)

Set myRefPlane = swModel.FeatureManager.InsertRefPlane(4, 0, 1, 0, 0, 0)

MsgBox ("PLANE CREATED")

End Sub

 

WHAT I SEE AFTER RUNNING MACRO

##

Outcomes