Jump to content
Developer Wiki and Function Reference Links ×

control points 101


Recommended Posts

OK.  I feel like I'm getting closer.  Will I figure it out before I slowly go insane?

 

This gets the end of the polyline text in the right place, but the control point is in the wrong place.  

 

What am I doing wrong?

 


Procedure Test;



VAR


SeatNumH, ObjectHandle, tempHandle,			
ControlGeometry,								 
objectHand, recordHand, wallHand			: HANDLE;

XCordOffset, YCordOffset,					
Rx,Ry,												
ControlLength 								: REAL;

BTest										: BOOLEAN;	

PtAlongPath, TangentAtPoint					: VECTOR;

Sx,Sy,				
objectName,			
CurrentClass								: STRING;

Pt											: POINT;


BEGIN

CurrentClass := ActiveClass;

BTest := GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand);

ControlGeometry := GetCustomObjectPath(objectHand);


ControlLength := HLength(ControlGeometry);

BTest := PointAlongPoly(ControlGeometry,1", PtAlongPath,TangentAtPoint);




{	MoveTo(pControlPoint01X,pControlPoint01YY);}


	Rx := pControlPoint01X;
	Ry := pControlPoint01YY;

	TextOrigin(Rx,Ry);
	BeginText;
	'BEGIN HERE'
	EndText;
	
	SetTextVerticalAlign(LNewObj,3);
	SetTextJust(LNewObj,2);
	SetPenColorByClass(LNewObj);
	SetFPatByClass(LNewObj);
	SetFillColorByClass(LNewObj);
	SetTextStyleByClass(LNewObj);
										


BTest := PointAlongPoly(ControlGeometry,ControlLength - 1", PtAlongPath,TangentAtPoint);



	
	{MoveTo(pControlPoint02X+PtAlongPath.x+24,pControlPoint02YY+PtAlongPath.y+24);}
	
	Rx := pControlPoint02X + PtAlongPath.x;
	Ry := pControlPoint02YY + PtAlongPath.y;
	
Sx := Num2StrF(Rx);	
SetRField(objectHand, 'BeginningAndEnd', 'pControlPoint02X',Sx);

Sy := Num2StrF(Ry);
SetRField(objectHand, 'BeginningAndEnd', 'pControlPoint02YY',Sy);

Message(
'X: ',pControlPoint02X,CHR(13),
'Y: ',pControlPoint02YY);



	TextOrigin(Rx,Ry);
	
	BeginText;
	'END HERE'
	EndText;
	
	SetTextVerticalAlign(LNewObj,3);
	SetTextJust(LNewObj,2);
	SetPenColorByClass(LNewObj);
	SetFPatByClass(LNewObj);
	SetFillColorByClass(LNewObj);
	SetTextStyleByClass(LNewObj);
										


END;									



RUN(Test);

 

Link to comment
3 hours ago, michaelk said:

Message( 'X: ',pControlPoint02X,CHR(13), 'Y: ',pControlPoint02YY);

I'd be interested to know if you're getting a result here - if so what.

 

Probably also if you could expand it to;

Message( 'X: ',pControlPoint02X,CHR(13), 'Y: ',pControlPoint02YY, 'Sx: ', Sx, 'Sy: ', Sy);

Just so you could see if those two values are being put / converted in correctly.

 

The minor problem I can kinda see coming is once the user moves the "End Here" control point pair there's the potential you'll overwrite that data fresh when you make any other refresh to the POI, in anyway (I could be [probably am] wrong here) - as such you might want to put a comparator, something along the lines of (presuming the reference for control points is 0,0 in this context - syntax will be wrong); 

If((PControlPoint02X<>0),Sx:=Num2StrF(Rx),'')

 

Like I said syntax aside that *might* be a thing worth doing.

 

Someone here surely has dealt with floating control point boxes which aren't by default at the start of a polyline...

 

J

Link to comment

I think you have a number of issues confounding your troubleshooting. 

 

Was the screen shot of the param names from the Script Editor? If so, do they look the same in the Plug-in Manager?  If so, my guess is that the extra Y is a Script Editor bug and that you’re not accessing the field. 

 

HLength() I not going to be accurate for polylines. The call that gets the perimeter is better (without looking at the reference, I think it’s HPerimeter() ). In the SDK this is failing for objects with only 2 points, so double check returned values. 

 

Finally, in order to see the control points in the new position, you have to reset the object. As James mentions, this could get you into trouble, as you could have an infinite loop. You either need to store old values and do a comparison, or use object states to only set values on creation or when another parameter has changed. 

Link to comment

Joshua

 

Yes, that pict is from the Script Editor.  It does NOT match the plug-in manager definition.  But I get an unidentified variable error if I don't add the extra Y.

 

I haven't found HLength to give me bad results.  I have found that the tangent at a point on a polyline is sometimes very inaccurate if the polyline is an arc and the point is at the end (double click point).  That's why I'm adding 1" to the beginning and subtracting 1" from the end.

 

James - stellar idea.  I'll give that a try.

Link to comment
11 hours ago, michaelk said:

Yes, that pict is from the Script Editor.  It does NOT match the plug-in manager definition.  But I get an unidentified variable error if I don't add the extra Y.

 

This sounds to me like a bug — I would report that. I’m also inclined to think the Set/GetRField commands still want the correct field name, without the extra “Y,” which may be different than the PParam access. 

 

And don’t forget about the reset issue. You won’t see the control points in the new position until after you reset the object. 

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