Jump to content
Developer Wiki and Function Reference Links ×

Join lines inside PIO


Pi_

Recommended Posts

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).

Link to comment

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...

Link to comment

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);

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...