MaxStudio Posted October 2, 2008 Share Posted October 2, 2008 Does anyone know how to write, or where I can find, a script to draw a simple rectangle and offset that rectangle. I would like to be able to have an input dialogue box pop up with asking for the size of the rectangle and the offset. Quote Link to comment
Pat Stanford Posted October 2, 2008 Share Posted October 2, 2008 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 Quote Link to comment
MaxStudio Posted October 2, 2008 Author Share Posted October 2, 2008 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. Quote Link to comment
Pat Stanford Posted October 2, 2008 Share Posted October 2, 2008 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 Quote Link to comment
MaxStudio Posted October 2, 2008 Author Share Posted October 2, 2008 Wonderful!!!! thank you. I've done some programming before so I am picking this up. is there a way to define the attributes for each rectangle i create? (line weight, fill) Quote Link to comment
MaxStudio Posted October 2, 2008 Author Share Posted October 2, 2008 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! Quote Link to comment
Pat Stanford Posted October 2, 2008 Share Posted October 2, 2008 The full Vectorscript reference is available in the VectorWorks on-line help. The Rect command does not return a handle. Try something like this in the middle: Rect (X1,Y1, X1+R1, Y1+R2); A1:=LNewObj; Rect(X1+R3,Y1+R3, X1+R1-R3, Y1+R2-R3); B1:=LNewObj; SetLW(A1,12); SetFPat(B1, 2) SetFillBack(B1, 2, 2, 2); Pat Quote Link to comment
MaxStudio Posted October 2, 2008 Author Share Posted October 2, 2008 YES! I GOT IT! Thanks Pat! Quote Link to comment
MaxStudio Posted October 3, 2008 Author Share Posted October 3, 2008 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. Quote Link to comment
Miguel Barrera Posted October 3, 2008 Share Posted October 3, 2008 You need to create your own custom dialog. The ones you listed are already preset with fields and cannot be modified. 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.