Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set active work plane

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
Adamchuk_Nicolay
8126 Views, 10 Replies

Set active work plane

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.

10 REPLIES 10
Message 2 of 11
saikat
in reply to: Adamchuk_Nicolay

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
Message 3 of 11
Adamchuk_Nicolay
in reply to: saikat

Dear Saikat!

 

Thank you for advance.

Try to use it.

Message 4 of 11

any idea how to set workplane from existing planes of the view?
Message 5 of 11
Joe.Ye
in reply to: Ning_Zhou

 

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
Message 6 of 11
Ning_Zhou
in reply to: Joe.Ye

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

Message 7 of 11
Joe.Ye
in reply to: Ning_Zhou

 

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
Message 8 of 11
Ning_Zhou
in reply to: Joe.Ye

right, thanks Joe & have great weekend!
Message 9 of 11
Jason_Miller6
in reply to: saikat

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.

Message 10 of 11
zhounnin
in reply to: Jason_Miller6

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

Message 11 of 11
paolomod3nese
in reply to: saikat

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();
                    }

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community