'1. Ensure that the specified model exists.
'2. Run the macro.
'3. Creates Ground Plane1 in the Ground Planes folder of
' the FeatureManager design tree and modifies it.
'===========================================================================
Set swApp = Application.SldWorks
Set Part = swApp.OpenDoc6("C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2019\samples\tutorial\api\assem2.sldasm", 2, 0, "", longstatus, longwarnings)
Set swAssembly = Part
swApp.ActivateDoc2 "assem2.sldasm", False, longstatus
Set Part = swApp.ActiveDoc
Set featmgr = Part.FeatureManager
boolstatus = Part.Extension.SelectByRay(-0.124913770805165, 0.118854842937424, 7.02747343940473E-02, -0.620586476260429, -0.617739368127351, -0.482980846978724, 3.09726603088958E-03, 2, True, 0, 0)
Set ent = Part.SelectionManager.GetSelectedObject6(1, -1)
Set swGPData = featmgr.CreateDefinition(swFmGroundPlane)
swGPData.PlanarEntity = ent
Set feat = featmgr.CreateFeature(swGPData)
Part.ClearSelection2 True
Set featdata = feat.GetDefinition()
boolstatus = Part.Extension.SelectByRay(0.119119826446138, 5.16103810082313E-03, 0.183494239718641, -0.620586476260429, -0.617739368127351, -0.482980846978724, 3.09726603088958E-03, 2, False, 0, 0)
Set ent = Part.SelectionManager.GetSelectedObject6(1, -1)
featdata.AccessSelections Part, Nothing
featdata.PlanarEntity = ent
feat.ModifyDefinition featdata, Part, Nothing