Jump to content
Developer Wiki and Function Reference Links ×

My first Script, Comments Please.


justin1974

Recommended Posts

This is my first script attempt, it creates a 2D, 3D pivoting door. Feel free to use the script. Anyone who could comment on the way I'm scripting and give areas for efficiency etc it would be good to get some feed back.

For some reason when I put the plugin object into the drawing, a bunch of black control handles appearing in the centre of the page. They are clearly a ghost outline of the object created from the 0,0 coordinates of the page. They can not be selected but are annoying. How can I get rid of them?.

PROCEDURE pivotDoor;

VAR

offset,Clpen,Width,Height,thick,rtpoint1,rtpoint,arcpt:Real;

ang,r,g,b:Integer;

Arc1,Arc2:Handle;

on3d:Boolean;

PROCEDURE GreyPen; {gets the rgb from Colour Index}

BEGIN;

ColorIndextoRGB(52,r,g,b);

END;

PROCEDURE draw3d;

BEGIN;

BeginXtrd(0,Height);

Rect(-width/2,-thick/2,width/2,thick/2);

EndXtrd;

Breakwall(0,width,false);

dselectall;

END;

PROCEDURE draw2d;

BEGIN;

dselectall;

Rect(-width/2,-thick/2,width/2,thick/2);

Locus(rtpoint,0);

Rotatepoint(rtpoint,0,ang);

dselectall;

Case ang OF

0:message('door closed');

-3600..-1,1..3600: begin;

Arc(-width/2,-rtpoint1,(-width/2)+(2*rtpoint1),rtpoint1,180,Ang);{smallarc}

Arc1:=Lnewobj;

SetLW(arc1,1);

SetPenFore(Arc1,r,g,b);

SetFpat(arc1,0);

Arc(width/2,width/2-rtpoint,-width/2+rtpoint+rtpoint,-width/2+rtpoint,0,ang);{bigarc}

Arc2:=Lnewobj;

SetLW(arc2,1);

SetPenFore(Arc2,r,g,b);

SetFpat(arc2,0);

dselectall;

end;

End;

END;

BEGIN;

width:=Pwidth;

height:=Pheight;

thick:=Pthickness;

rtpoint1:=PPivot;

ang:=Pangle;

rtpoint:=-width/2+rtpoint1;

Offset:=Poffset;

greypen;

Draw2d;

Draw3d;

Dselectall;

End;

Run (pivotdoor);

Link to comment

Looks good for your first PIO script. To clean the screen up after the execution of a PIO add SetZoom(GetZoom);

after Dselectall; There is also redraw; (For the last created object in VS) and redrawall; (For redrawing all objects on screen), but these commands work well for other types of scripts but not as well for PIO's.

Dave

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