How to Create Line based on Angle

How to Create Line based on Angle

Anonymous
Not applicable
5,852 Views
5 Replies
Message 1 of 6

How to Create Line based on Angle

Anonymous
Not applicable

I have element line location in Revit code (first line).

Then i need to add second line. 

The second line start point is any point on the line which is 90 degrees from the first line on X/Y Axis.

I cant get method to create second line based on angle.

Below is the example of the line i need.

I have been playing around with method CreateTransformed, CreateRotationAtPoint and CrossProduct but i still don't get the result i want.

Thanks.

 

Line.png

0 Likes
Accepted solutions (1)
5,853 Views
5 Replies
Replies (5)
Message 2 of 6

aignatovich
Advisor
Advisor
Accepted solution

Hi! It is simple, just get a) line direction b) line sketch plane normal

Then normal.CrossProduct(direction) should be your second line direction or, may be, you need -1*normal.CrossProduct(direction)

Take any point on first line, for example, pt1 = fistLine.Evaluate(0.5, true), pt2 = pt1 + length * direction, then create the second line Line.CreateBound(pt1, pt2), then create model curve on the first line sketch plane, base on this second line

Message 3 of 6

Anonymous
Not applicable

Thanks a lot Ignatovich. 

 

Here is my code based on your solution:

 

Line line1 = Line.CreateBound(XYZ.Zero, new XYZ(10, 10, 10));
XYZ pntCenter = line1.Evaluate(0.5, true);
XYZ normal = line1.Direction.Normalize();
XYZ dir = new XYZ(0, 0, 1);
XYZ cross = normal.CrossProduct(dir);
XYZ pntEnd = pntCenter + cross.Multiply(10);
Line line2 = Line.CreateBound(pntCenter, pntEnd);
Debug.Print("line1: " + line1.Direction.ToString());
Debug.Print("line2: " + line2.Direction.ToString());
Debug.Print("line1: Start " + line1.GetEndPoint(0).ToString() + " End " + line1.GetEndPoint(1).ToString());
Debug.Print("line2: Start " + line2.GetEndPoint(0).ToString() + " End " + line2.GetEndPoint(1).ToString());

 

Smiley Very Happy

Message 4 of 6

strsuraj
Enthusiast
Enthusiast

Hi, @aignatovich how about creating a reference plane at a particular angle say 33 degrees. Do we have a direct method, where we can pass desired angle as an argument.

0 Likes
Message 5 of 6

joldman473
Participant
Participant

Hi  @aignatovich,

Can you please show me how to get the  line sketch plane normal:

when I create it a plane by a normal ( my line direction) and an origin line origin.

The cross product plane.Normal(line.Direction) Will be equal to (0,0,0) because the two vectors have the same direction.

 

Thanks in advance.

0 Likes
Message 6 of 6

aignatovich
Advisor
Advisor
sketchPlane.GetPlane().Normal
0 Likes