Change normal of drafting view plane

Change normal of drafting view plane

Anonymous
Not applicable
848 Views
5 Replies
Message 1 of 6

Change normal of drafting view plane

Anonymous
Not applicable
Hello everyone, I have a lot of model lines which are all in XZ plane (Y=0). I want to create detail lines in a drafting view from these model lines. However, the drafting view plane is XY plane (Z=0), and my code throws “curves must be in the plane”. I do not want to change my model lines because that needs a lot of modification to my add-in. Is there a way to change the normal of drafting view to other directions? or some other ways to accomplish this? Thanks
0 Likes
Accepted solutions (1)
849 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

The ViewDrafting SketchPlane property is read-write, so you might be able to change it as you please:

 

https://www.revitapidocs.com/2020/2531634f-f0d4-3cb3-7f8a-fe809d33a61f.htm

 

Can you create a drafting view through the user interface that does not lie in the XY plane with Z equal to zero?

 

If so, you can presumably do so programmatically as well.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Jeremy,

Thanks for your reply. I followed your suggestion to set the ViewDrafting SketchPlane property. But it throws an exception. Following is my code:

public static ViewDrafting Create_Drafting_View(Document doc)

        {

            ViewFamilyType viewFamilyType = new FilteredElementCollector(doc)

            .OfClass(typeof(ViewFamilyType)).Cast<ViewFamilyType>()

            .FirstOrDefault(q => q.ViewFamily == ViewFamily.Drafting);

 

            Transaction trans = new Transaction(doc, "create drafting view");

            trans.Start();

            ViewDrafting draftView = ViewDrafting.Create(doc, viewFamilyType.Id);           

            Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisY, XYZ.Zero);

            SketchPlane skplane = SketchPlane.Create(doc, plane);

            draftView.SketchPlane = skplane;

            trans.Commit();

 

            return draftView;

        }

 

draftView.SketchPlane = skplane throws exception “Model lines can not be drawn in current view”. I guess the error message means the drafting view do not accept model lines and SketchPlane can not be set. I tried to do this manually through UI, but there is no options for setting the plane normal.

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk

Well, if it can't be done, then it can't be done, can it?

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 6

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

transform the Curves, not the View.

 

In this very old post you can find a GetTransformToZ method which will help you to rotate your Curves into a XY plane, with an arbitrary Z value

https://thebuildingcoder.typepad.com/blog/2009/03/transform.html

You will also need to translate them from Z to zero to fit the requirements of the ViewDrafting (Which originates in 0/0/0).

 

For a given Curve, you can get a transformed copy by curve.CreateTransformed(yourTransformation).

 

 

Revitalizer

 

 




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 6 of 6

Anonymous
Not applicable

 

Thanks for the suggestion. I believe the curves can be moved to any direction and place we want, but that will cause a lot of changes to my code. I will just use section view to display the detail curves.

0 Likes