Jump to content
Developer Wiki and Function Reference Links ×

Extrude rectangle


Recommended Posts

tismacfan2,

    I am not sure exactly what you want, but the following script will create a rectangular Extrude object of 0-height on the Layer Plane, but you must draw it in Top/Plan or Top view. Since it is already an Extrude, you can use the OIP to set its Extrude Height, and Bottom Z-value.

 

   If you want to use this as a Tool, a different approach will be needed. (i.e., more code).

PROCEDURE RectExtrude;
{ Draw a Rectangle, convert it to an Extrude w/ ZERO height. }
{ Extrude height and Bottom Z value can then be changed in the OIP. }
{ The initial rectangle is drawn on the Layer Plane. }
{ This script works as expected in Top and Top/Plan views, }
{ but in other 3D views the rectangle shifts position. }
{ 7 Jan 2018 - Raymond J Mullin }
VAR
	H :Handle;
	X1, Y1, X2, Y2 :Real;
BEGIN
	GetRect(X1, Y1, X2, Y2);
	Rect(X1, Y1, X2, Y2);
	H := HExtrude(LNewObj, 0, 0);
END;
Run(RectExtrude);

 

HTH,

Raymond

Link to comment

Thank you for trying helping me. I am from Belgium and my English is not so good for a good explanation what is want.

I attach a draw so you can maybe know better what  I want.  I already make a script but the problem is that he said it is ok by checking, but when

I use it nothing is on my screen and al the menu's off Vectorworks became gray,  so I must always shut down Vectorworks.

 

Perhaps you can help me when you see my drawing with explanation.

 

Thank you very much for helping me solving this problem.

Pascal

Schermafbeelding 2018-01-07 om 11.34.45.png

Link to comment

this is my script what I have made

 

Procedure Kopplaat;

VAR 
eventID, eventMessage : LONGINT;
d,h,b:REAL;
bp,kop,db,ab,tk:STRING;
objectHandle:HANDLE;
boolResult:BOOLEAN;


BEGIN


PushAttrs;
b:=PLineLength;
h:=Pboxwidth;
d:=Pd;
ab:=Pab;
db:=Pdb;
kop:=Pkop;
bp:=Pbp;
tk:=Ptk;


BeginXtrd(0,d);

Rect(0,0,b,h);

objectHandle := LNewObj;
SetDropShadowData(objectHandle, 0,0.1,0.05,#315.0000000000d,75,0,0,0);
EnableDropShadow(objectHandle, FALSE);
objectHandle := LNewObj;
SetObjectVariableBoolean(objectHandle, 1160, FALSE);
boolResult := SetEntityMatrix(objectHandle, 0,0,0,0,-0,0);

EndXtrd;


SetZVals(0,0);

    
    
    


    

PopAttrs;
END;


Run (Kopplaat);

Link to comment

I have try to make another script but also here I get errors

 

Procedure kopplaat;
var
kop, ab,db,d,x,y,x1,y1,xo,yo:real;

h,hl: handle;


begin

DSelectAll;

kop:=Pkop;
ab:=Pab;
db:=Pdb;
d:=Pd;

BeginXtrd(0,d);
        GetRect(x,y,x1,y1);
        Rect(x,y,x1,y1);
EndXtrd;

h:=LNewObj;
        hl:=MakePolyline(h);

end;
run(kopplaat);

 

but when I make it on this way de errors are ( see pict 2)

second problem the script doesn't' work in other views than 2d plan

can someone please help me

kind regards and thank you

Schermafbeelding 2018-01-07 om 18.31.06.png

Schermafbeelding 2018-01-07 om 18.31.42.png

Link to comment

tismacfan2,
   You have defined "ab" and "db" to be REAL numbers. If I translate "Keuzelijst" correctly it means "pick list", or "pop-up" in the English version of VW. The value of "Pab" will be of type STRING, even if the data in "Pab" represents a number.  All elements in a Pop-up list are of type STRING. You will have to use Str2Num() to make the assignment.

 

TRY:
ab := Str2Num(Pab);

db := Str2Num(Pdb);
 

  Your parameter "Pd" should be a number as its type is Afmeting, or Dimension. It's possible the error on line #15 will go away when the errors on the previous lines are corrected.

 

Raymond

Edited by MullinRJ
Link to comment

Dear Raymond

 

I have change the script in this way

 

Procedure kopplaat;
var
x,y,x1,y1,xo,yo:real;
ab,db:string;


h,hl: handle;


begin
ab := Str2Num(Pab);
db := Str2Num(Pdb);

DSelectAll;


BeginXtrd(0,0);
        GetRect(x,y,x1,y1);
        Rect(x,y,x1,y1);
EndXtrd;

h:=LNewObj;
        hl:=MakePolyline(h);

end;
run(kopplaat);

 

And the error list you can find in the file.

 

What have I to use if I want put text in it.

kop must give a result in text.

 

Thank you very much

Pascal

Schermafbeelding 2018-01-09 om 08.03.20.png

Link to comment

Pascal,

   From your original script, I assume you want to use "ab" and "db" as real numbers. The values stored in the Plug-in that you reference as "Pab" and "Pdb" are STRINGs. To use them as numbers you use the Str2Num() function. You need to leave the original type declaration for "ab" and "db" as REAL.

 

So:
VAR
    ab, db :REAL;
...
BEGIN
    ab := Str2Num(Pab);        { converts Pab from STRING to REAL }
    db := Str2Num(Pdb);        { converts Pdb from STRING to REAL }

...

 

This should make your code snippet compile.

 

HTH,

Raymond

Link to comment

Raymond

 

I have stil some problems and questions about my script

 

Procedure kopplaat;
var
ab,db,kop,x,y,x1,y1,xo,yo:real;
h,hl: handle;


begin
ab := Str2Num(Pab);  
db := Str2Num(Pdb); 
kop:=Pkop;


DSelectAll;


BeginXtrd(0,d);
        GetRect(x,y,x1,y1);
        Rect(x,y,x1,y1);
EndXtrd;

h:=LNewObj;
        hl:=MakePolyline(h);

end;
run(kopplaat);

 

1.

I put a text Kop to real, this must give me the possibility to put text in the info pallet. ( for the moment error see pict)

What can I do to solve this.

 

2. in the row BeginXrd(0,d) I put a parameter d ( this must me give the possibility to put a value in the info pallet, with give me the thickness of the extrusion. ( but als error)

where must I put the "d" is that also by real?

 

3. When I select the "kopplaat" wich I have drawn I don't see in the info pallet kopplaat but only extortion and I don't see in field to put my ab, or db, kop or tickness in ( see fig)

 

4. how can I solve that the rectangle will be drawn in every view, front, behind, left or right. For the moment it go only in 2d

 

Can you help me further please.

thank you very much

Pascal

 

Schermafbeelding 2018-01-11 om 13.53.34.png

Schermafbeelding 2018-01-11 om 13.56.06.png

Link to comment

Pat,

 

I don't have any errors anymore in my script with your tips, but why don't I see the settings of the script in the info pallet?

In the info pallet I only see Extrusie(extrusion) and not the name of my script " kopplaat linck" (pict 1)

And I can't also not give the values in the info pallet of db, ab, kop (pict 2)

 

here is the script without errors.

Procedure kopplaat;
var
ab,db,kop,d,x,y,x1,y1,xo,yo:real;
h,hl: handle;


begin
ab := Str2Num(Pab);  
db := Str2Num(Pdb); 
kop:=Str2Num(pkop);

DSelectAll;


BeginXtrd(0,pd);
        GetRect(x,y,x1,y1);
        Rect(x,y,x1,y1);
EndXtrd;

h:=LNewObj;
        hl:=MakePolyline(h);

end;
run(kopplaat);

 

Thank you

Pascal

Schermafbeelding 2018-01-12 om 23.14.20.png

Schermafbeelding 2018-01-12 om 23.14.30.png

Link to comment

It sounds like you have not created a PlugIn object but rather just a script. You can't have parameters show in the OIP from a script, but you can from a PlugIn.

 

Copy the script and go to the PlugIn Editor. Create a new PlugIn. Paste the script into the Script pane. Edit the Parameters pane to show all of the items you want to display in the OIP, but with just the name without the P in front.

 

You should probably read the section on the Vectorscript Language Guide on PlugIns before you proceed.

 

http://developer.vectorworks.net/images/7/72/VectorScriptGuide.pdf

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