Jump to content
Developer Wiki and Function Reference Links ×

Two copies of 3D Poly in PIO


PeterT

Recommended Posts

I have a simple PIO that draws a 3D Poly, and it has a parameter to draw the Poly with either no fill or solid fill.

If I place the PIO in the drawing with no fill set as a default parameter, it draws one 3D Polygon with no fill, as expected.

But when I place the PIO and set the parameter to solid fill, the PIO draws TWO 3D Polygons with solid fill.

Does anybody know what is going on here? Why am I getting two Polys instead of one? I am working in VectorWorks 12.5.2.

Link to comment

The 3D poly code is only part of a much larger plugin, but I have reduced it to just the 3D poly portion. I have tested this stand alone portion, and as I stated before, if the parameter OpaqueGlass is TRUE AND FillPat(1) is called, the Draw3D Glass subroutine draws two 3D polygons instead of one.

Procedure Glass;

{Parameters:	
Width:			DIMENSION
Height:			DIMENSION
HeadHeight:		DIMENSION
OpaqueGlass:		BOOLEAN
}

VAR
Width:  		REAL;
Height: 		REAL;
HeadHeight: 	REAL;
OpaqueGlass:  	BOOLEAN;

{---------------------------------------------------------------------}
PROCEDURE Draw3DGlass;

VAR
x1, z1, x2, z2: REAL;

BEGIN	
	x1:=(-Width/2)+2;
	z1:=HeadHeight-2;
	x2:=x1+Width-4;
	z2:=z1-Height+4;

	ClosePoly;
	BeginPoly3D;
		Add3DPt(x1,0,z1);
		Add3DPt(x2,0,z1);
		Add3DPt(x2,0,z2);
		Add3DPt(x1,0,z2);
	EndPoly3D;
END;
{---------------------------------------------------------------------}

BEGIN    {Main}

{Set attributes}
PushAttrs;
FillFore(0,0,0);
FillBack(65535, 65535, 65535);
PenFore(0,0,0);
PenBack(65535, 65535, 65535);
FillPat(0);
PenPat(2);
PenSize(1);


	Width :=           	PWIDTH_OF_WINDOW;
Height:=           	PHEIGHT_OF_WINDOW;
	HeadHeight:=       	PHEAD_HEIGHT;
OpaqueGlass:=	POPAQUE_GLASS;

BEGIN
	IF OpaqueGlass = TRUE THEN
	BEGIN
		FillPat(1);
		Draw3DGlass;
	END ELSE

	FillPat(0);
	Draw3DGlass;

END;
PopAttrs;
END;

RUN(Glass);

You will have to place this code in a Plugin and add the four parameters in order to test it. That is why I at first was just asking if anyone knew of any anomalies about drawing 3D polys inside of plugins.

Link to comment

Hi Peter,

???You are calling Draw3DGlass twice when OpaqueGlass is TRUE, and once when it is FALSE. This is because your ELSE clause did not have a BEGIN and END encompassing the following 2 statements and only the next statement was included in your ELSE clause. The second Draw3DGlass was getting executed every time, even when OpaqueGlass was TRUE.

Try this for your main body:

BEGIN    {Main}
	Width := PWIDTH_OF_WINDOW;
Height := PHEIGHT_OF_WINDOW;
	HeadHeight := PHEAD_HEIGHT;
OpaqueGlass := POPAQUE_GLASS;

{Set attributes}
PushAttrs;
FillFore(0,0,0);
FillBack(65535, 65535, 65535);
PenFore(0,0,0);
PenBack(65535, 65535, 65535);
PenPat(2);
PenSize(1);

IF OpaqueGlass THEN     { is the same as: IF (OpaqueGlass=True) THEN }
	FillPat(1)
ELSE
	FillPat(0);

Draw3DGlass;     { Only call this once }
PopAttrs;
END;
RUN(Glass);

HTH,

Raymond

Link to comment

Raymond,

Thanks, that was a rookie mistake. My brain just could not see it. I wrote the plug-in a long time ago, but did not notice the problem with it until recently. It took a lot to get back into the plug-in to search for the error as the full code is 750 lines. I now have the plug-in commented much better so the next time I have to mess with it, I can find the offending section faster.

And thanks for pointing out that I should get the subroutine call out of the IF THEN clause entirely. You gave me several examples of how I can shorten my code quite a bit. Some day, I need to go back into many of the scripts I have written and clean them up.

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