ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
MDM. Doga Dogan05/07/2017

Hello,

I would like to write a macro that creates a new plane with a given distance dynamically, and then starts a 2D sketch on it. Therefore I need to select the newly created plane before I start the sketch. I couldn't understand how to choose a newly created plane.

My current code looks like this:

    Dim myRefPlane As Object

    Distance = Distance / 1000

    Set myRefPlane = Part.FeatureManager.InsertRefPlane(8, Distance, 0, 0, 0, 0)

    Part.ClearSelection2 True

    boolstatus = Part.Extension.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

    Part.SketchManager.InsertSketch True

The code above just assumes that the new plane is called Plane1, however, this might not be the case. Any ideas?

Thank you