Get rotation or direction from selected object (polyline)

Is there a way to get rotation from a selected object and pass that to mtext and block rotation…
I thought I had found this earlier in the year but can’t seem to find a sample.

You could use Line.Direction to get a directional vector for the Polyline, then use Vector.AngleAboutAxis to measure the angle relative to the X axis.

Hi
Convert polyline to alignment
And Using this is

If I’m using a polyline, I’d guess I need to create a line from the polyline to get the vector direction. does that sound right?
I was going to use an alignment at first, then I thought it would be simpler with the polyline. maybe I’ll try the alignment over the weekend, or could I do an alignment from the polyline. I think I was that in the polyline group.

Thanks Guys

If the polyline is just a single segment, then two ways you might do it:

  1. Geometry.Explode, which will get it down to a Line in order to use Line.Direction.
  2. Get the start and end points and then use Vector.ByTwoPoints
  3. Use Curve.TangentAtParameter, which should give the same result for any parameter between 0 and 1 assuming that the polyline consists of a single, straight segment.

Your quick, I was just adding the alignment from profile.

yes it’s one segment. Will try what you have suggested first.

couldn’t I just change selected object from polyline to line then get the line by direction, that might be faster to test. I only used poly because I thought user would use poly before line.

Thank you.

All three of these should work whether it’s a line or a polyline.

If it’s one line segment, use lines then you can use objectextension.getparameterbyname (from the toolkit) and input “Angle” and you can convert that to degrees using the Math.RadianToDegrees node.

Also, Camber has “PointExtensions.AngleBetweenPoints” node and if you got geometry of the polyline you can get begin and end points get the angle from x axis.

Good call Kirk, I didn’t even think to suggest a node from my own package. Kinda embarassing, huh? :rofl:

1 Like

Thanks guys,

I’ll try that today.

One thing I noticed today is the offset equal spaced by number is including blocks for the start point but not at the end point. Is there a property to include at end point or way a that I can create points equally spaced to add include the end point of the selected polyline/baseline. If there is not a way to do that,
would the additional node to add blocks at that end still be included in the block count?

Thanks for all your help

There are lots of ways you could do it. Curve.EndPoint will give you the end, and then you just add it to the end of whatever list of points you have. If you’re using a list of parameters to get the points, then just make sure you have a parameter of 1 in the list, which will always be the end point.

Same logic if you’re using coordinate systems instead of points. Curve.CoordinateSystemAtParamter with a parameter of 1 will give you a coordinate system at the end.

Thanks guys, I learn a lot this week. I was able to apply the rotation from KirkWM suggestion.
I added the Curve.CoordinateSystemAtParamter with the 1 parameter… when I isolate that I do get the blocks inserted at the end point, however I don’t see how to add those points to the existing list of points. I did look at the primer list helps but didn’t see how I could add to the my list given how my script was setup. or how I’d add if I started with a new script. I’m still pretty new at this so some of the terms still are still new. would it be possible to show how to add that additional point a list.

Thank you so much for your help.
runway-lites.dwg (1.4 MB)

INSERT RUNWAY EDGE LIGHTS BY POLYLINE.dyn (79.3 KB)

The List.AddItemToEnd node should do what you need.

Thanks MZjensen,

I got it, thanks to your help

Here’s another way just for fun

image

Kirk,

Thanks I’ll try that