Showing results for 
Search instead for 
Do you mean 
Reply

Trim a line to an intersection C++

Hello all

 

Any advice on writing a function in C++ to split 2 intersecting lines across their intersection point?

5 REPLIES

Re: Trim a line to an intersection C++

 

Use the DivideCurveBuilder, and set the type to:

 

Features:Smiley Very HappyivideCurveBuilder::TypesByBoundingObjects

 

Record a Journal with your User Interface Journal preferences set to C++ to see the whole process.  You will of course have to substitute either curve selection or some other method of your choosing to specify the curves.

 

Re: Trim a line to an intersection C++

Thank you! Im trying to write a script to find the intersection of 2 arbitrary lines, is there a way to detect if a line intersects any others and then split both over that intersection?

Re: Trim a line to an intersection C++

are you assuming they are in the same plane, or do you have to check if they are skewed?

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Trim a line to an intersection C++

They're in the same plane. My end goal is to be able to clean up a set of lines so there are no colinear or crossing lines.

Re: Trim a line to an intersection C++

You have to first collect all the lines. Then iterate each line and check itersection with all other lines.

 

Below is the function to find whether two lines are intersected or not

 

int UF_MODL_intersect_curve_to_curve
(

tag_t curve1_id,
tag_t curve2_id,
int* num_intersections,
double* * data

)

 

tag_tcurve1_idInputfirst curve or edge to intersect
tag_tcurve2_idInputsecond curve or edge to intersect
int*num_intersectionsOutputnumber of intersections
double* *dataOutput to UF_*free*It is a one dimensional array whose size is num_intersections 5
data[5i + 0], data[5i + 1] and data[5i + 2] holds the coordinates of the point
data[5i + 3] holds the parameter of first curve or edge
data[5i + 4] holds the parameter of second curve or edge

 

After that you can trim those lines or delete as per your requirement.