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: 

LocationCurve.Curve throwing Error

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Simon.Pusateri
209 Views, 2 Replies

LocationCurve.Curve throwing Error

Hello all,

 

Running into an error that seems like it should be fairly simple to fix but it is giving me issues. I am trying to get the curve geometry of an object, but am having issues when trying to access the Curve Element via LocationCurve. 

SimonPusateri_0-1655930644652.png


When I run my code I get the following error when execution hits the last line shown (used some debugging to confirm this).

SimonPusateri_1-1655930733825.png


My main goal of getting the curve is to determine the angle of object (in this case a grid, but I may be expanding scope to include walls and beams which is why I am not simply casting the element as Grid) relative to the horizontal.

 

Any help is appreciated!

2 REPLIES 2
Message 2 of 3

The Grid class doesn't implement the Location property that is why you get null.

 

You can use Grid.Curve

 

If the Curve is a Line you can use:

XYZ.Basis.X.AngleOnPlaneTo(Line.Direction, XYZ.Basis.Z)

 

I generally prefer AngleOnPlaneTo instead of AngleTo since it measures angle anticlockwise from 0 to 2xPi. Whereas AngleTo measures only between 0 and Pi (not an absolute angle).

 

However it should be noted that although grid direction can be measured from 0 to 2xPi above the opposite direction would largely be irrelevant for most grid purposes i.e. angle could in the end be converted to the range of 0 to < pi.

 

So depends if your angle needs to uniquely identify opposite grid directions or not. You get similar issue with rotation of symmetrical columns.

 

Message 3 of 3

The Grid class doesn't implement the Location property that is why you get null.

 

AH! This is good to know - I had gotten things working with Grid.Curve but thought this might make it easier to expand my program to allow for other types. I'll just have to implement a bit of logic to get around this. 

Thanks for pointing this out!

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community