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: 

drawing in a "section" view

10 REPLIES 10
Reply
Message 1 of 11
bcampbell11
2627 Views, 10 Replies

drawing in a "section" view

ok, I have been stuck on something for quite a while now, sorry if it is a newby question.  When wanting to draw a line via the Revit api, all works perfect as long as the view is a drafting view.  How can I draw in a section or elevation without having to figure out what direction I am looking for the x,y,z?  How do you make the current view "normal" to where x is to the right and y is up the page?  Any thoughts? 

Thanks!!

10 REPLIES 10
Message 2 of 11

If you have XYZ coordinates, it should work on any view, unless you change what's visible.

Is it a model line?
Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 3 of 11

these are model lines.  So are you saying, no matter how the section is cut, X should always be to the right, and Y should always be up?  I that is the case, I am missing something, when I cut a section and draw a line via .net, XY and Z are different depending on which way the section cut is looking.

 

would detail lines behave better?

 

Thanks

Message 4 of 11

Maybe I missing something on your question... can you append a few lines where you create it?

The Model Line should have "absolute" XYZ coordinates, but are bound to a sketch plane. Now the Detail Line are bound to a specific view.
Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 5 of 11
Revitalizer
in reply to: bcampbell11

Hi bcampbell,

 

as far as I understand your question, you just want to draw lines in a 2D context, as if using GDI methods.

It is okay to ignore the Z value in drafting views (using value 0 for it) since those views reside in a XY plane on elevation 0.

 

In elevation views and section views, you are forced to use the transformed geometry of your proposed lines.

This means you need to calculate the transform of your target view, using its origin and up, right and view direction vectors.

 

 

Revitalizer

 

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 6 of 11

I have done some pretty cool things with the Revit api (in my opinion) but to simply draw a line seems to be one of the most difficult things you can do with the Revit API (Autocad is much much easier).  

 

Lets try a model line, could you explain to me why even trying to get the example below from the SDK tells me "Curve must be in the plane".  and by "absolute" do you mean anywhere in the model, looking any direction, I can a line that goes up and to the right with the same coordinates?  Not a lot of good resources out there for this kind of thing unfortunately, hard to learn.

 

Thanks 

 

' get handle to application from document
Dim application As Autodesk.Revit.ApplicationServices.Application = document.Application

' Create a geometry line in Revit application
Dim startPoint As New XYZ(0, 0, 0)
Dim endPoint As New XYZ(10, 10, 0)
Dim geomLine As Line = Line.CreateBound(startPoint, endPoint)

' Create a geometry arc in Revit application
Dim end0 As New XYZ(1, 0, 0)
Dim end1 As New XYZ(10, 10, 10)
Dim pointOnCurve As New XYZ(10, 0, 0)
Dim geomArc As Arc = Arc.Create(end0, end1, pointOnCurve)

' Create a geometry plane in Revit application
Dim origin As New XYZ(0, 0, 0)
Dim normal As New XYZ(1, 1, 0)
Dim geomPlane As Plane = application.Create.NewPlane(normal, origin)

' Create a sketch plane in current document
Dim sketch As SketchPlane = SketchPlane.Create(document, geomPlane)

' Create a ModelLine element using the created geometry line and sketch plane
Dim line__1 As ModelLine = TryCast(document.Create.NewModelCurve(geomLine, sketch), ModelLine)

' Create a ModelArc element using the created geometry arc and sketch plane

Message 7 of 11

For a line like this, that lies on the XY plane (Z=0), the SketchPlane should be on the same plane

Dim startPoint As New XYZ(0, 0, 0)
Dim endPoint As New XYZ(10, 10, 0)
Dim geomLine As Line = Line.CreateBound(startPoint, endPoint)

Dim origin As New XYZ(0, 0, 0)
Dim normal As New XYZ(0, 0, 1) ' vector in Z
Dim geomPlane As Plane = application.Create.NewPlane(normal, origin)
Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 8 of 11

so, did you just change this line in the example???

 

from:

Dim normal As New XYZ(1, 1, 0)

to:

Dim normal As New XYZ(0, 0, 1)

 

either way, it produces the same error.

 

 

Message 9 of 11

This code works for your model line:

 

XYZ origin = new XYZ(0, 0, 0);
XYZ normal = new XYZ(0, 0, 1);
Plane plane = app.Create.NewPlane(normal, origin);
SketchPlane skplane = SketchPlane.Create(doc, plane);

XYZ startPoint = new XYZ(0, 0, 0);
XYZ endPoint = new XYZ(10, 10, 0);
Line l = Line.CreateBound(startPoint, endPoint);
ModelLine ml = doc.Create.NewModelCurve(l, skplane) as ModelLine;

Now your code for arc is a bit different as the points are in a more complex scenario... so let's try a more generic approach with CrossProduct from end1 and pointOnCurve and using end0 as origin for the plane

 

XYZ end0 = new XYZ(1, 0, 0);
XYZ end1 = new XYZ(10, 10, 10);
XYZ pointOnCurve = new XYZ(10, 0, 0);
Arc a = Arc.Create(end0, end1, pointOnCurve);

XYZ origin = end0;
XYZ normal = end1.CrossProduct(pointOnCurve);
Plane plane = app.Create.NewPlane(normal, origin);

SketchPlane skplane = SketchPlane.Create(doc, plane);
ModelArc ml = doc.Create.NewModelCurve(a, skplane) as ModelArc;

And I hope my math is ok 🙂

 

Form wikipedia, just in case: https://en.wikipedia.org/wiki/Cross_product

220px-Right_hand_rule_cross_product.svg.png

 

 

 

 

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 10 of 11
Anonymous
in reply to: augusto.goncalves

I know this is an old post, but I wonder if you found the way to get point XYZ (start and end) for the detail line to always match the viewplane (to draw on the view plane)?

Message 11 of 11

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

Post to forums  

Autodesk Design & Make Report