Trim/Extend Element Method ?

Trim/Extend Element Method ?

mr.engineer.aec
Advocate Advocate
3,964 Views
9 Replies
Message 1 of 10

Trim/Extend Element Method ?

mr.engineer.aec
Advocate
Advocate

 Hi guys,

I'm trying write add-in to extend beam into face of column.
But, i can't find any something about Revit API to action

How can i solved this issue ?
Many thanks.
New Bitmap Image.jpg

0 Likes
3,965 Views
9 Replies
Replies (9)
Message 2 of 10

kevin.anggrek
Enthusiast
Enthusiast

I also want to know further about this issue. I am currently interested in extending one Line element to another.

For example I have 2 simple lines such as shown below:

 

XYZ ptA = XYZ.Zero;
XYZ ptB = new XYZ(10, 0, 0);
XYZ ptC = new XYZ(5, 5, 0);
XYZ ptD = new XYZ(5, 10, 0);

Line line1 = Line.CreateBound(ptA,ptB);
Line line2 = Line.CreateBound(ptC,ptD);

 

 How can I extend line2 so it touches with line1? I tried looking at the SDK Documentation and the revitapidocs for Lines, Curves, XYZ and I still have no clue. I find something called TrimExtendCurves Method but don't know how to use it properly, if it is limited to Rebar elements only or if it is even relevant with the current issue at all.

0 Likes
Message 3 of 10

vkelani
Contributor
Contributor

@kevin.anggrek 
you can get the intersection of two lines P(I), and check the distance of between intersection points and each end point of the line you want to extent. Whichever is short distance, you can replace that endpoint it by P(I) in create line bound.

you’ll get the desired extension. 
@mr.engineer.aec  same concept can be applied for walls and columns, I am not really sure what geometry element they are but you can use RevitLookup to see the geometry type and create the logic.

 


cheers!

Vish. K.

0 Likes
Message 4 of 10

kevin.anggrek
Enthusiast
Enthusiast

Dear @vkelani ,

Unless I misunderstood your explanation, the two lines I mentioned before are not intersecting with each other yet and thus if I use the Line.Intersects Method, no intersection point would be obtained at all (Null IntersectionResult as the result of the method). Could you elaborate further on what you mean by getting the intersection point between two lines that are not intersected with each other?

 

Thank you

0 Likes
Message 5 of 10

Revitalizer
Advisor
Advisor

Hi,

 

just elongate your lines to find the proposed intersection point.

A line's direction and its negative are the vectors you need to find the start and end point of the elongated line.

 

 

Reitlizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 6 of 10

vkelani
Contributor
Contributor

Dear Kevin,

 

The lines are not intersecting but you can get the intersecting point by making your own method, because that’s the point you want to extend your first line right?, now for method, you can get the great explanation on geometric calcs by Mr. Tammik on thebuildingcoder.typepad.com.

 

@mr.engineer.aec  with a quick search, I found, there’s a “FindColumns” sample provided on thebuildingcoders.typepad.com blog. 

hope this helps.

 

cheers!

Vish. K.

0 Likes
Message 7 of 10

RPTHOMAS108
Mentor
Mentor

Can probably find the intersection via Line.CreateUnbound you'll get the direction from each line by deducting one end from the other and then normalising the XYZ, origin can be any point on the line i.e either end point.

 

Above is for straight lines if you have arcs then you can do similar but you'll have more than one intersection, however  only one of those intersections is nearest to the original end of the beam considered. You can't create an unbound but you can create one that is between 0 and 2Pi.

Message 8 of 10

vkelani
Contributor
Contributor

Edit*:

After implementing your method or one by thebuildingcoder, the code would be simply-

XYZ intersection = util.intersection(line 1, line 2)

And then you can extend line 1 to line 2 (intersection point).

 

Hope this helps!

Cheers!

Vish. K.

Message 9 of 10

kevin.anggrek
Enthusiast
Enthusiast

Thanks to everyone for the replies

 

@RPTHOMAS108,

Thank you sir for the detailed explanation, by using CreateUnbound, I can basically elongate the line and find the intersection points that I need. Then, I can change the endpoints to the intersection point as a way to extend the line just as explained by @vkelani.

 

@Revitalizer,

Yes sir, by knowing the direction vector of the line, I can elongate the line just as mentioned by @RPTHOMAS108 

 

@vkelani 

Wow, I am amazed that Mr. Tammik has already created another Intersection method that takes two unbound lines as input. This could greatly simplify the process of finding the intersection points. Thank you very much

0 Likes
Message 10 of 10

mr.engineer.aec
Advocate
Advocate

 Many thanks all replies.

At the end, don't have any method to action.
I think i'll get end point and project on to face.
Although it seem manual but i think it can be useful.

Many thanks for the help

0 Likes