Pi_ Posted June 30, 2014 Share Posted June 30, 2014 Hi, I want to join lines inside a PIO (the lines are a result of 'GetObjectHiddenLine'). The lines are in a group, I can select them but I cannot join them (DoMenuTextByName('Compose',0) The command works in a script but not inside a PIO. I tried ungrouping the group, entering the group (FinGroup),... the selected items seem to be the lines+PIO itself, Nextobj after FSobject gives nil (first selected object is PIO itself). Quote Link to comment
Miguel Barrera Posted July 2, 2014 Share Posted July 2, 2014 If you can select them, then you should be able to change the end points. You can find the intersection point with: PROCEDURE LineLineIntersection( l1start :POINT; l1end :POINT; l2start :POINT; l2end :POINT; VAR parallel :BOOLEAN; VAR intOnLines :BOOLEAN; VAR sectpt :POINT); Quote Link to comment
Pi_ Posted July 3, 2014 Author Share Posted July 3, 2014 thanks Miguel, I was looking for one command to join all lines in group, I ended up making an array of points: >>take first line end point >>loop trough all ellements in the group >>check begin and endpoints >>if beginpoint matches add endpoint to array and vice versa and delete element >>loop again from beginning with new endpoint >>draw polyline with array of points... a lot of work, it works , but 'join(handle1,handle2)' would be so much easier... Quote Link to comment
Miguel Barrera Posted July 7, 2014 Share Posted July 7, 2014 Piet, The following code will let you select 2 lines and will join them similar to the way is done with the Join menu command. The Join procedure is the same format that you suggested: PROCEDURE JoinLines; VAR line1Hdl,line2Hdl: HANDLE; selPt: POINT3D; FUNCTION CheckObjCallback(h : HANDLE; px, py : REAL) : BOOLEAN; BEGIN IF GetType(h) = 2 THEN CheckObjCallback:= TRUE ELSE CheckObjCallback:= FALSE; END; PROCEDURE Join(VAR line1,line2: HANDLE); VAR dist1,dist2: REAL; parallel, intOnLines : BOOLEAN; ln1beg,ln1end,ln2beg,ln2end,intPt: POINT; BEGIN GetSegPt1(line1,ln1beg.x,ln1beg.y); GetSegPt2(line1,ln1end.x,ln1end.y); GetSegPt1(line2,ln2beg.x,ln2beg.y); GetSegPt2(line2,ln2end.x,ln2end.y); LineLineIntersection(ln1beg,ln1end,ln2beg,ln2end,parallel,intOnLines,intPt); dist1:= Distance(ln1beg.x,ln1beg.y,intPt.x,intPt.y); dist2:= Distance(ln1end.x,ln1end.y,intPt.x,intPt.y); IF dist1 > dist2 THEN SetSegPt2(line1,intPt.x,intPt.y) ELSE SetSegPt1(line1,intPt.x,intPt.y); dist1:= Distance(ln2beg.x,ln2beg.y,intPt.x,intPt.y); dist2:= Distance(ln2end.x,ln2end.y,intPt.x,intPt.y); IF dist1 > dist2 THEN SetSegPt2(line2,intPt.x,intPt.y) ELSE SetSegPt1(line2,intPt.x,intPt.y); END; BEGIN TrackObject(CheckObjCallback, line1Hdl, selPt.x, selPt.y, selPt.z); IF line1Hdl <> NIL THEN BEGIN SetSelect(line1Hdl); TrackObject(CheckObjCallback, line2Hdl, selPt.x, selPt.y, selPt.z); IF line2Hdl <> NIL THEN BEGIN SetSelect(line2Hdl); Join(line1Hdl,line2Hdl); END; END; END; Run(JoinLines); Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.