Jump to content
Developer Wiki and Function Reference Links ×

Simple script to draw a rectangle and offset?


Recommended Posts

Try this as a starting point.

Procedure OffsetRectangle;

Var R1,R2,R3:Real;

S1:String;

X1, Y1 :Real;

Begin

S1:='Enter the width, Height and Offset for the desired Rectangles, then click the start location';

PtDialog3D(S1,'Width','Height','Offset',R1, R2, R3);

GetPt(X1,Y1);

Rect(X1,Y1,X1+R1,Y1+R2);

Rect(X1+R3,Y1+R3, X1+R1-R3, Y1+R2-R3);

End;

Run(OffsetRectangle);

Pat

Link to comment

Hey thanks Pat.

Do I create this as a text file? Or do I use the VectorScript Editor? If I do use the VSE how do I go about inserting the code. I'm just starting with vectorscript and I feel as though once I get a handle on a simple script like this I should be able to dissect it.

Link to comment

The easiest way is to use the Vectorscript editor.

Select everything between the

Procedure

and the end of the line that starts

Run.

Go to your resource browser and create a new Vectorscript in your current document. It will also make you create a script palette.

Once the script editor is open, just paste the script in.

On the top menu bar is a button that looks like a gear. This does a syntax check on the script to make sure it is ok. If it passes, then click the OK button to get back to the drawing.

Double click on the script name in the script palette to run the script.

To get back to the editor, hold down the Option key while you double click the script in the script palette. Or you can choose the script in the resource browser and select edit from there.

Pat

Link to comment

I've been looking for some answers online. Would I have to define a handle for each object (rectangle) where i define the variables? Then use a setpenfore and setfillfore to specify colors? and setLW to specify line weight?

If so how do I set the rectangle=to the handle?

Procedure OffsetRectangle;

Var R1,R2,R3:Real;

S1:String;

X1, Y1 :Real;

A1, B1:Handle;

Begin

S1:='Enter the width, Height and Offset for the desired Rectangles, then click the start location';

PtDialog3D(S1,'Width','Height','Offset',R1, R2, R3);

GetPt(X1,Y1);

A1:=Rect(X1,Y1,X1+R1,Y1+R2);

B1:=Rect(X1+R3,Y1+R3, X1+R1-R3, Y1+R2-R3);

SetLW(A1,12);

SetFPat(B1, 2)

SetFillBack(B1, 2, 2, 2);

End;

Run(OffsetRectangle);

I tried this exact script as a test but it failed!

Link to comment

Hey Pat is there anyway to have more than 3 input fields in a dialog box? The PtDialog only allows 2 for x,y coordinates. The PtDialog3d only allows 3 for x,y,z coordinates. The RealDialog only allows for 1 variable?

Is there a way to set the number of input fields in a dialog box? I have more variables than 3 and do not want to have multiple dialog boxes popping 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...