Jump to content
Developer Wiki and Function Reference Links ×

Nested PIOs - retrieve value from child PIO


Yancka

Recommended Posts

I'm "treading in unchartered territory" of nested PIOs. Need some help.

Child PIO is "2D Quadrilateral", mother PIO is "2D Quadrilateral Assembly". Into assembly PIO I insert 2 "2D Quadrilateral" instances. The first one is rectangle. The second is square. I want to place the square besides the rectangle (I'm using HMove). For that I need to calculate the distance. I fail to get the actual distance with

"MidRectWidth:=Str2Num(GetRField(MidRect,'2D Quadrilateral','Box Width'));"

I'm getting only default value for 'Box Width' parameter. Meantime in schedules everything is OK and the values are correct.

May be this is due to some shortcomings in overall logics of my PIOs and standard size settings? The code of "2D Quadrilateral":

PROCEDURE Quadrilateral;
VAR
RectWidth, RectHeight :REAL;
PluginHandle, PluginRecordHandle, PluginWallHandle :HANDLE;
PluginName :STRING;
BEGIN
IF GetCustomObjectInfo(PluginName,PluginHandle,PluginRecordHandle,PluginWallHandle) THEN BEGIN
RectWidth:=PBox_Width;
RectHeight:=PBox_Height;
{PluginHandle:=FSactLayer;}

IF PCustom_size=false THEN
	BEGIN
		EnableParameter(PluginHandle,'Box Width',false);
		EnableParameter(PluginHandle,'Box Height',false);
		IF PQuadrilateral_type='Square' THEN
			BEGIN
				IF PSquare_standard_size='A1' THEN RectWidth:=350;
				IF PSquare_standard_size='A2' THEN RectWidth:=680;
				IF PSquare_standard_size='A3' THEN RectWidth:=975;
			END;
		IF PQuadrilateral_type='Rectangle' THEN
			BEGIN
				IF PRectangle_standard_size='T1' THEN BEGIN RectWidth:=350; RectHeight:=680; END;
				IF PRectangle_standard_size='T2' THEN BEGIN RectWidth:=680; RectHeight:=975; END;
				IF PRectangle_standard_size='T3' THEN BEGIN RectWidth:=975; RectHeight:=1550; END;
			END;
	END
ELSE
	BEGIN
		EnableParameter(PluginHandle,'Square standard size',false);
		EnableParameter(PluginHandle,'Rectangle standard s',false);
	END;

IF PQuadrilateral_type='Rectangle' THEN SetParameterVisibility(PluginHandle,'Square standard size',false) ELSE
	BEGIN
		SetParameterVisibility(PluginHandle,'Rectangle standard s',false);
		EnableParameter(PluginHandle,'Box Height',false);
		RectHeight:=RectWidth;
	END;

SetRField(PluginHandle,'2D Quadrilateral','Box Width',Num2Str(0,RectWidth));
SetRField(PluginHandle,'2D Quadrilateral','Box Height',Num2Str(0,RectHeight));

MoveTo(-RectWidth/2,0);
Rect(-RectHeight,#90,RectWidth,#0);
END;
END;
Run(Quadrilateral);

And the code of "2D Quadrilateral Assembly":

PROCEDURE QuadrilateralAssembly;
VAR
PluginHandle, PluginRecordHandle, PluginWallHandle, MidRect, LeftSquare :HANDLE;
PluginName :STRING;
XOffset, MidRectWidth, LeftSquareWidth: REAL;

BEGIN
IF GetCustomObjectInfo(PluginName,PluginHandle,PluginRecordHandle,PluginWallHandle) THEN BEGIN

MidRect:=CreateCustomObjectN('2D Quadrilateral',0,0,0,false);
SetRField(MidRect,'2D Quadrilateral','Quadrilateral type','Rectangle');
SetRField(MidRect,'2D Quadrilateral','Rectangle standard s',GetRField(PluginHandle,'2D Quadrilateral Assembly','Rectangle standard s'));
SetRField(MidRect,'2D Quadrilateral','Custom size','false');

LeftSquare:=CreateCustomObjectN('2D Quadrilateral',0,0,0,false);
SetRField(LeftSquare,'2D Quadrilateral','Quadrilateral type','Square');
SetRField(LeftSquare,'2D Quadrilateral','Custom size','false');

MidRectWidth:=Str2Num(GetRField(MidRect,'2D Quadrilateral','Box Width'));
LeftSquareWidth:=Str2Num(GetRField(LeftSquare,'2D Quadrilateral','Box Width'));
XOffset:=-(MidRectWidth+LeftSquareWidth)/2;
HMove(LeftSquare,XOffset,0);
END;
END;
Run(QuadrilateralAssembly);

Link to comment
You cannot get values for the child pio because it has not been created yet. The mother pio needs to complete to actually create the child.

Sounds quite reasonable. Thanks!

I guess that leaves no other option than store standard size information in both - child & parent plugins. I was hoping there would be a workaround for it.

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