PeterT Posted March 26, 2008 Share Posted March 26, 2008 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. Quote Link to comment
Dieter @ DWorks Posted March 26, 2008 Share Posted March 26, 2008 What's the code? Whithout code, we can't see what's wrong Quote Link to comment
PeterT Posted March 27, 2008 Author Share Posted March 27, 2008 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. Quote Link to comment
MullinRJ Posted March 27, 2008 Share Posted March 27, 2008 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 Quote Link to comment
PeterT Posted March 27, 2008 Author Share Posted March 27, 2008 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. Quote Link to comment
MullinRJ Posted March 28, 2008 Share Posted March 28, 2008 My pleasure, Peter. Glad I could help. Raymond-3 Quote Link to comment
Recommended Posts
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.