Set active work plane

Adamchuk_Nicolay
Enthusiast
Enthusiast

Set active work plane

Adamchuk_Nicolay
Enthusiast
Enthusiast

Hi,

 

is it possibility to set active work plane for some view ?

There are ..ActiveView.ShowActiveWorkPlane() and

HideActiveWorkPlane() but how to set active plane ?

 

Thank you for advance.

0 Likes
Reply
Accepted solutions (2)
8,411 Views
10 Replies
Replies (10)

saikat
Autodesk
Autodesk
Accepted solution

Hi

 

The following code shows how to creata a new SketchPlane and assign it as the active workplane.

 

 

 

      UIApplication uiApp = commandData.Application;

      UIDocument uiDoc = uiApp.ActiveUIDocument;

 

      // Setting workplane

      using (Transaction transaction = newTransaction(uiDoc.Document, "tt"))

      {

        transaction.Start();

        Plane plane = newPlane(uiDoc.ActiveView.ViewDirection, uiDoc.ActiveView.Origin);

        SketchPlane sp = uiDoc.Document.Create.NewSketchPlane(plane);

        uiDoc.ActiveView.SketchPlane = sp;

        uiDoc.ActiveView.ShowActiveWorkPlane();

        transaction.Commit();

      }

 

I hope this helps.

cheers

 



Saikat Bhattacharya
Senior Manager - Technology Consulting

Adamchuk_Nicolay
Enthusiast
Enthusiast

Dear Saikat!

 

Thank you for advance.

Try to use it.

Ning_Zhou
Advocate
Advocate
any idea how to set workplane from existing planes of the view?
0 Likes

Joe.Ye
Alumni
Alumni

 

Hi Ning,

 

Yes, you can. Saikat's code create a sketch plane from scratch. You can also call SketchPlane.Create(Reference refPlanar) to create a sketch plane using an existing planar plane.

public static SketchPlane Create(
	Document document,
	Reference planarFaceReference
)

 

 


______________________________________________________________

If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!

 

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
0 Likes

Ning_Zhou
Advocate
Advocate

thanks Joe, what i mean is how to set workplane fron existing list, see attached JPG.

0 Likes

Joe.Ye
Alumni
Alumni
Accepted solution

 

Hi Ning,

 

Sorry for the misunderstanding.

You can get the SketchPlane from the existing document. SketchPlane instances are store in Revit document. Just follow the element filtering way to get your target sketch plane.

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network

Ning_Zhou
Advocate
Advocate
right, thanks Joe & have great weekend!
0 Likes

Jason_Miller6
Participant
Participant

I know this is an older post. Can the solution to this be applied with Dynamo in the Code Block or Python? I not too familiar with python, but I think this route would help me achieve what I am trying to in Dynamo and get the work plane set before placing elements. Not sure what my input and output need to be set at.

0 Likes

zhounnin
Advocate
Advocate

zero touch is the way to go if not doable in Python

0 Likes

paolomod3nese
Enthusiast
Enthusiast

The method for the creation of the Plane has changed, in case anyone needs this i'll leave a code snippet:

 

using(Transaction t = new Transaction(doc, "Creating sketchplane"))
                    {
                        t.Start();
                        Plane plane = Plane.CreateByNormalAndOrigin(doc.ActiveView.ViewDirection, doc.ActiveView.Origin);
                        SketchPlane sp = SketchPlane.Create(doc, plane);
                        doc.ActiveView.SketchPlane = sp;
                        t.Commit();
                    }