Jump to content
Developer Wiki and Function Reference Links ×

Calculated Control Point


Recommended Posts

Not sure if this is possible, and I've probably asked this before, but here's a another try!

 

In a parametric object I want to calculate a point, put a control point there and draw some geometry located at that control point.  I get the first part, but when the user moves the control point the object is moving but not the handle.

 

Is this even possible?

 

Thanks!

 

 

Procedure Test;

CONST
	CR 					= 	CHR(13);
	GiveMeAnX			=	500mm;
	GiveMeAY			=	200mm;
													
	
VAR
	objHd,recHd,wallHd,											
	ControlGeometry
													: HANDLE;
													
	resultStatus					
													: BOOLEAN;
	
	objName, currentClass
													: STRING;
	
	i				
													: INTEGER;
													

	


BEGIN
	PushAttrs;
	currentClass := ActiveClass;
	resultStatus := GetCustomObjectInfo(objName,objHd,recHd,wallHd);
	ControlGeometry := GetCustomObjectPath(objHd);
	SetObjectVariableBoolean(objHd, 800, TRUE);  	
	
	

	RectangleN(	0,0,
				1,0,
				GiveMeAnX,GiveMeAY);

	SetRField(objHd,GetName(recHd),'ControlPoint01X',Num2StrF(GiveMeAnX));
	SetRField(objHd,GetName(recHd),'ControlPoint01Y',Num2StrF(GiveMeAY));

	RectangleN(	pControlPoint01X,pControlPoint01Y,
				1,1,
				20mm,20mm);
				
					


	NameClass(currentClass);
	PopAttrs;	
END;

RUN(Test);

 

Test 1 2 3.vso

Link to comment

Your GiveMeAX and GiveNeAY are constants. You don’t read the ControlPoint values.

Try this (I did this on my iPhone so there are no indents):

 

Procedure Test;

CONST

CR = CHR(13);

 

VAR

objHd,recHd,wallHd, ControlGeometry : HANDLE;

resultStatus : BOOLEAN;

objName, currentClass : STRING;

i : INTEGER;

rX, rY: REAL;

 

BEGIN

PushAttrs;

currentClass := ActiveClass;

resultStatus := GetCustomObjectInfo(objName,objHd,recHd,wallHd);

ControlGeometry := GetCustomObjectPath(objHd);

SetObjectVariableBoolean(objHd, 800, TRUE);

 

rX := pControlPoint01X;

rY := pControlPoint02Y;

 

RectangleN( 0, 0, 1, 0, rX, rY);

 

RectangleN( rX, rY, 1, 1, 20mm, 20mm);

NameClass(currentClass);

PopAttrs;

END;

 

RUN(Test);

Link to comment

I think the part you are missing is that you have to write the Control Point values back to the parameters at the end of the script.  Look at Reading the parameters at the top and writing them back at the bottom.

 

Procedure Test;

CONST
	CR 					= 	CHR(13);
	GiveMeAnX			=	500mm;
	GiveMeAY			=	200mm;
													
	
VAR
	objHd,recHd,wallHd,											
	ControlGeometry
													: HANDLE;
													
	resultStatus					
													: BOOLEAN;
	
	objName, currentClass
													: STRING;
	
	i				
													: INTEGER;
													

	workX, workY								: Real;


BEGIN
	PushAttrs;
	currentClass := ActiveClass;
	resultStatus := GetCustomObjectInfo(objName,objHd,recHd,wallHd);
{	ControlGeometry := GetCustomObjectPath(objHd);
	SetObjectVariableBoolean(objHd, 800, TRUE);  	
}	

			WorkX := pControlPoint01X;
			WorkY  := pControlPoint01Y;
		
		

{	RectangleN(	0,0,
				1,0,
				GiveMeAnX,GiveMeAY);
}


	RectangleN(	pControlPoint01X,pControlPoint01Y,
				1,0,
				GiveMeAnX,GiveMeAY);
				
	
	SetRField(objHd,GetName(recHd),'ControlPoint01X',Num2StrF(WorkX));
	SetRField(objHd,GetName(recHd),'ControlPoint01Y',Num2StrF(WorkY));

	NameClass(currentClass);
	PopAttrs;	
END;

RUN(Test);

 

Link to comment

Thanks @Peter Vandewalle & @Pat Stanford.

 

Sorry for the slow replay.  I'm currently in Internetless Lakes.

 

The point GiveMeAnX,GiveMeAY is only meant to be the initial position of the control point.  It is calculated by the plugin - not defined in the plugin definitions.  After that I want the user to be able to move it around at will.  (The first rectangle is only there to remind me where the initial point was).

 

In your example, Peter, the control point starts out at it's definition point.  I want to specify the initial location from the script.

When I try your's Pat the diamond square moves but the control point doesn't follow it.

 

Is there a good way to assign an arbitrary location for a control point that is still moveable by the user?

 

Link to comment

I may have been barking up the wrong tree!

 

This does what I want:

Procedure Test;

CONST
	CR 					= 	CHR(13);
	GiveMeAnX			=	500mm;
	GiveMeAY			=	200mm;
													
	
VAR
	objHd,recHd,wallHd,											
	ControlGeometry
													: HANDLE;
													
	resultStatus, UseDefaultPositions					
													: BOOLEAN;
	
	objName, currentClass
													: STRING;

BEGIN
	PushAttrs;
	currentClass := ActiveClass;
	resultStatus := GetCustomObjectInfo(objName,objHd,recHd,wallHd);
{	ControlGeometry := GetCustomObjectPath(objHd);
	SetObjectVariableBoolean(objHd, 800, TRUE);  	
}	
	RectangleN(	0,0,
				1,0,
				GiveMeAnX,GiveMeAY);

	UseDefaultPositions := IsNewCustomObject(objName);
				
	IF UseDefaultPositions THEN 
		BEGIN
			SetRField(objHd,GetName(recHd),'ControlPoint01X',Num2StrF(GiveMeAnX));
			SetRField(objHd,GetName(recHd),'ControlPoint01Y',Num2StrF(GiveMeAY));
		END;
	
	RectangleN(	pControlPoint01X,pControlPoint01Y,
				1,1,
				200mm,200mm);

	NameClass(currentClass);
	PopAttrs;	
END;

RUN(Test);

 

 

Seems obvious now :-).  Thanks for your help Pat & Peter!

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