Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  
Yancka

Custom object displaying insertion Z value

Recommended Posts

Hi folks. I haven't been much doing VW scripting and would like to get initial advise. I want to create a custom 3D object (steel beam) which in plan view would display it's bottom Z value as a text and also it's ID. Z value is bottom point of that particular object instance. It could be something like combining 2D/3D symbol with stake object. :)

Is it possible with VScript? And which way to look at? With 2D/3D symbols I'm out of luck. And does the term "plug-in" in VS mean the same as in VW usage (say, door is a plug-in object)?

Share this post


Link to post

Yes, it is possible and a plug-in object (PIO) means the same. For a steel beam, I would create a line plug-in and extrude the beam profile along the line. For the text, you can either have a fixed origin or add control points to move the text origin to the desired location.

You can find examples in the Vectorscript support page

Share this post


Link to post

Thanks Migel! That's good news!

I already visited the site you mention and tried to run those scripts. For some reason I succeed to run only the basic like "Create New Layer" but all of those others in plug-in section I received an error alert. So I didn't experience the relief of seeing any successfully created custom plug-in.

The way I used the code was copying it from .vss file and pasting it into new script within my resources in resource browser. May be that's wrong? And how to deal with .vso files? Quite embarrassing but I didn't find anything on .vso in VW help... and quick search in internet also doesn't bring much light. Before some time I did it (vso) but now I can't recall.

Could you please post a code of simple custom plug-in here if it's not too difficult?

Edited by Yancka

Share this post


Link to post

Yancka

Welcome to the world of wondering what Vector Script Can do for you.

To get started go to your VectorWorks Help. This should open in your web browser.

file:///Applications/Vectorworks%202009/VWHelp/wwhelp/wwhimpl/js/html/wwhelp.htm

There is a section called-Vector Script Language Guide. This is where to start.

I recommend you use an external editor to write your scripts.

I use BBedit- you can trial for 1 month free. Alternatively there is TextWrangler for free. The advantage of these are they have all the Functions programmed, when you type in a function the text turns blue. This will save many hours looking for one letter misplaced that will break your code.

The tool you want to make is quite simple in VS. It should take a couple hours to write and test. BUT If it is your first it will take you up to a week.

Recommend process for you to explore.

Step 1.

Create a line tool object that simply draws you a line. Get it working so you can stretch the line.

Step 2

Figure out how to Draw the section you want to extrude. Suggest you start with a simple box. Then add complexity of how to draw a complex polyline.

Step 3

Figure how to use the BeginXtrd and EndXtrd to extrude object you had drawn

Step 4

Use Set3DRot to rotate the extrude into the correct plane. Note you may need to do this in two steps. You will get a different result if you rotate about both X&Z in one step, than if you rotate first about X, Then second rotate Z.

Step 5

Use Move3Dobj to move the beam up in the Z value as needed. At this point you will want to add a parameter to the plugin that represents the z Value.

Note Steps 4 & 5 both require you to have a Handle on the object you are rotating / moving. I use a generic hObject as my handle. I would use hObject:=lnewobj; after creating the extrude.

Step 6

Add Text

use TextOrigin, BeginText and EndText to create a text object. If you want to use the Z value from the object parameters you will need to covert the number to a String with Num2Str.

Good Luck

Share this post


Link to post

Yancka

This basic script for a steel beam should get you started. It uses the extrude along path object to simplify the orientation of the extrude and will save you the headaches trying to figure out the rotations needed to show correctly.

Share this post


Link to post
Step 1.

Create a line tool object that simply draws you a line. Get it working so you can stretch the line.

Well, finally I could get it but it was weird and works weird. I read the help at beginning and after succeeding to draw fixed line (with line function) and failing to get it stretchable I decided to look in other .vso files (strange thing with VW help on MAC - with keywords "vso" it gives no results but with ".vso" or "*vso" does). After reducing other code to drawing lines part and matching every part of my plug-in to that other I managed to have mine working as well. But it works only if Plug-in's parameter name is LineLength (originally was used by other one - working plug-in). If I rename this parameter it looses it's grips and isn't stretchable anymore. Meantime changing the value in OIP reflects also on a line.

What has parameter name to do with object being stretchable or not?

Share this post


Link to post

LineLength is a reserved field and it is created automatically when you create the line plugin. If you want a different name on the Object Info Palette (OIP) then use the alias field for this purpose.

See the example I attached yesterday.

Share this post


Link to post

Step 2

Figure out how to Draw the section you want to extrude. Suggest you start with a simple box. Then add complexity of how to draw a complex polyline.

Step 3

Figure how to use the BeginXtrd and EndXtrd to extrude object you had drawn

Step 4

Use Set3DRot to rotate the extrude into the correct plane. Note you may need to do this in two steps. You will get a different result if you rotate about both X&Z in one step, than if you rotate first about X, Then second rotate Z.

Haven't had much time to work on this, anyway I have 1 question at the moment while trying to follow your steps. Once the poly (or whatever) is drawn, how can it be used with BeginXtrd and EndXtrd if extrude's profile requires it's description between BeginXtrd and EndXtrd? At least from quick look to these procedures in VS Reference it seems so.

Miguel, thanks for your comment!

Currently my code with simple extrude isn't working and reports an error on Line #5: ExtrHnd :HANDLE; { Error: Identifier not declared. } and { Error: Expected ; }. What's wrong with my ExtrHnd declaration?

PROCEDURE CustomExtrude;
VAR
ItemLength :REAL;
xRot, yRot, zRot :REAL
ExtrHnd :HANDLE;


BEGIN
ItemLength:= PLineLength;

MoveTo(0,0);
LineTo(ItemLength,0);

BeginXtrd(0,PLineLength);
	Rect(500,#90,200,#0);
EndXtrd;
ExtrHnd:=LNewObj;
xRot:=90;
yRot:=90;
zRot:=90;

SET3DRot(ExtrHnd, xRot, yRot, zRot , 0,0,0);
END;
Run(CustomExtrude);

Edited by Yancka

Share this post


Link to post

Yancka,

Unless you really want to learn about 3D rotations, there is no need to do all this if you use the "extrude along path" instead.

Look at the code in "Steel Beam.vso" above which draws the 3D W shape steel beam. You can enter the z value in the OIP and the steel beam will move up accordingly. All you need to do is customize the 2D part to show the label, elevation and draw the 2D beam as desired.

Share this post


Link to post

If you do want to learn VS then you will spend many hours scratching your head wondering why your script is not working. Read your error messages carefully. It did tell you that it Expected ; ... as Miguel tells you above. You will spend hours looking for small and simple syntax errors as you learn the language, but if you persevere working through the error list becomes quick indeed.

Miguel is correct, you can use extrude along a path. This may or may not be the best way to do what you want. I prefer to extrude and place my object, I do some quite complex geometry and as it is second nature I like this method.

Your script is almost there BUT i would suggest you do it each step of the way. Understand how each part works then move on to the next step.

Your have the correct structure in drawing the object between the Beginxtrd and Endxtrd.

Note also the finer point I made in Step 4 about rotating object in one go. Or using the rotate object twice.

Keep going you are almost there.

Share this post


Link to post

Thx, gents! It's fun to look at it and see it working! Round 1 is complete successfully. That one missing semicolon would have caused much of trouble, since I was checking the line 5 and following lines. Good reason to learn scripting with text editor (I installed Text Wrangler). Round 2 would be getting clear with general workflow I'm after (in order to make sure if this direction is the right one at all) and Round 3 would be polishing things.

The workflow I'm looking for is:

1. Create 3D item (custom steel beam) with fixed parameters (such as profile type and profile parameters, overall length). That's what symbols are for.

2. Place this 3D item in my drawing - set X, Y, Z, rotation and Text placement in plan view (done with Control Point). In Text is displayed bottom Z of specific instance, which is "Layer Z + Instance Z on that Layer". This could be reduced to having beam Layers with Z=0 and placing those beam items in appropriate height. My current plug-in does that.

3. Create worksheet with DB row showing my custom beams. Necessary columns are Beam Number, Parameters (currently the only one is length, in reality would be much more) and total number of those beams in my DLs.

With my current understanding this is out of scope of what VW can handle. Creating my custom item which is going to be used repeatedly (and definitely modified many times over it's life-time) normally means creating a symbol. Having different values within text (Z) and location of the same text means creating plug-in object. Meantime having it as full plug-in leaves a major error source in same name beams being with varying parameters. Does VW allow creating Symbol/plug-in hybrid with such conditions? Is it possible to have text changing depending on symbol insertion data if plug-in is a part of symbol? Do others see other options?

I thought about creating different plug-in for each beam. But what about making new project where beam numbers will be reset and beam types are going to be totally different? And how to get those many different plug-ins into 1 DB row in worksheet? I attach both, plug-in and VW file with situation I'm talking about (error possibility when plug-ins only are used). What else is confusing, the current plug-in reacts on changes in both - Z value and Height fields. Is it possible to have only one of them and keep the text being linked to beams actual height?

And for Round 3 the only question today is how to get text controlpoint's initial value to be half of LineLength?

Share this post


Link to post

um long explanation I don't understand.

If what you want is to be able to schedule your plugins with a worksheet it is straight forward.

Open a new file.

Draw your plug in

Use Create report

Search for objects with your plug in records attached. This will list all plugins of the type.

From there you can play different DB criteria to get what you want.

ReText Placement

x:=plinelength/2;

Share this post


Link to post
um long explanation I don't understand.

um... my apologies. I'll try to make it short. The long story was about overall logics of the task. On VS part you both have been very supportive. Many thanks for that!

The overall process. Architectural design of project is done. Structural components are next to do. They are counted and labeled by types. Steel Beam with certain profile and length parameters is named SB-1. Steel Beam with same profile parameters but different length would have different label. I place it (SB-1) in my drawings as needed. Many times. Say, totally 107 instances. Besides each beam (or group of similar beams) I place label and a number which represents bottom Z value if that beam. Then I create detailing drawing and structural section drawings. Finally I create schedule with Label, Count, Parameters of that specific type of beams.

The problem No1 with plug-ins. Architectural design of project changes. The beams SB-1 now are 1 meter longer. I have to manage parameters of 107 plug-in instances labeled SB-1 being same.

The problem No2 with plug-ins. If I place 107 instances of plug-in who must have exactly same parameters of profile & length there's a possibility that a plug-in with label SB-1 has different profile or length parameter than others. There will always be a question if all SB-1 beams are really same. Therefore pure plug-in usage here is an almost definite no-no.

This isn't very short again but take it as it is. Obviously these logic issues can't be described much shorter (Or I'm bad with expressing myself shortly). I think the issue about workflow I'm looking for being out of scope of capabilities of VW as a software package. In AutoCAD there are such a thing as fields which allow to display insertion information of specific block (in VW language - symbol) instance within that block and also dynamic blocks (in VW would be symbols with adjustable parameters, very close to plug-ins). This concept would allow to make it in my case.

The only workaround I see is to create different plug-in for different type of beams. That would solve issue about same label beams to be with same parameters. But that would create another issue of having many different plug-ins which are built to use only for 1 project. And scheduling info would require creating common Record Format which would be used with all plug-ins as second Record Format, so the Plug-in would require making records to that one common name record format which is something I'm currently not able to do with VS.

Thank you once again Miguel and Assembly for your assistance with VS! I've answered myself quite much about solution I'm looking for, while was writing these long explanations. Meantime, I see very good usage possibilities for such type of plug-ins in other parts of my workflow (slab panels).

Share this post


Link to post
Therefore pure plug-in usage here is an almost definite no-no.

Update: just finished conversation with my colleague and we agreed that this no-no is a yes-yes.

Because height information written manually is bigger source of possible errors and causes more headache than possibly varying parameters.

So forget my 2 long explanations and I'll come back with VS questions when I have them.

Share this post


Link to post

The other possibility is to use a combination of symbols and PIOs.

Create the PIO you want and place it in a symbol. Use the Link Text To Record to place the name of the beam with the symbol.

Then if you edit the symbol, all of the instances change.

Definitely some details to work out, but it should be doable.

Share this post


Link to post
The other possibility is to use a combination of symbols and PIOs.

Create the PIO you want and place it in a symbol. Use the Link Text To Record to place the name of the beam with the symbol.

Then if you edit the symbol, all of the instances change.

Definitely some details to work out, but it should be doable.

I've been doing even symbol with Text linked to record which is then placed again in other symbol. This second symbol is just in order to ensure the name of inserted symbol's instance isn't changed accidentally.

Main reasons (or some details to be worked out) why I find symbol approach not suitable and PIO approach more suitable are:

1. If text is linked to record within symbol it's location can't be adjusted for specific symbol instance (in AutoCAD attributes or movable text as part of dynamic block would do the trick).

2. If it is symbol the Z value isn't automatic as it is with custom made plug-in.

Am I wrong at some point?

Thx for your input anyway!

Edited by Yancka

Share this post


Link to post

Remember that PIOs are dynamic by definition and can also call other PIOs in the process to update a drawing as a whole. When you change a paramter, the PIO gets regenerated and the geometry and other parameters can change accordingly. If you already have a method to label the steel beams then it should not be a problem to implement it in the code.

Since I do not know what is the practice outside the US, are the steel beams standard sizes like the ones in VW or custom designed for each job? If standard, you can have a popup list of all beams and when the type changes so does the label and shape size. When the length changes then the label and geometry change and so on.

Can you post an example, including the schedule, of what you are trying to achieve?

Share this post


Link to post

I think Miguel is correct that a PIO is the correct option.

You can put the label text with a control point so you can move it where ever you want.

You can use a worksheet and SUM it on the various fields to make sure items with the same label are also the same length. Two SUM icons, one on the label field and a second on the Length should give you a single row for each length of items with the same label.

Share this post


Link to post

I haven't made a sample drawing yet. Instead I've been coding for most of the day. Some questions regarding VS:

1. Parenthesis in the name of Parameter doesn't allow to retrieve parameters value with MyVariable:=PParameter_Name_(TextInParenthesis); or otherwise. Is there an option at all to use Parameter Names with parenthesis in it's name?

ReText Placement

x:=plinelength/2;

2. Text with control point. Is it possible to set control point x:=plinelength/2 only when plug-in is inserted first time? And later let the user change it? Or may by it is possible make the button called "center label" which would make x:=plinelength/2?

3. Is it possible to manage overall code in subroutines without any variables which are passed to/from subroutine?

4. I'm trying to make standard sizes with possibility to make custom sizes. Currently changing standard sizes reflects with 1 click in OIP delay on 3D geometry. In the attachment is my plug-in in current stage. If you see anything else worth to advise, please go ahead.

Share this post


Link to post

1. PParameterName is like a constant. You can only assign its value to a variable. Why would you need something in parenthesis?

2. The control point is set initially at the origin. You can test for x = 0 & y = 0 and if true then relocate to the midpoint.

3. Yes. The main reason for having a subroutine is to use it at several points in the code where the variables passed will not always be the same. Moreover, if you plan to use the subroutine in other scripts it would be a good idea to make it self contained so you can just copy & paste or add it to a library without any modifications.

4. The delay may be caused by the code itself if certain operations regenerates the object more than once. By using the debugger you can tell how many times the code is executed.

Share this post


Link to post
1. PParameterName is like a constant. You can only assign its value to a variable. Why would you need something in parenthesis?

For having it look as I want in OIP. For same reason I tried to name a Parameter "I-Beam Size" and failed because of "-" sign within parameter name. Is there a possibility to have ()- or probably other special symbols in parameters name?

2. The control point is set initially at the origin. You can test for x = 0 & y = 0 and if true then relocate to the midpoint.

Thx, this works. Haven't polished yet just tested.

4. The delay may be caused by the code itself if certain operations regenerates the object more than once. By using the debugger you can tell how many times the code is executed.

I changed the order how information is changed between variables and parameters and it works. The trick was to set value to variable and then pass it to parameter in case of standard size.

I have couple new questions.

5. What's a common manner (if there is any) of getting reasonable tool icons?

6. Parameter names. I have a pop-up parameter which determines type of beam. Then, based on type chosen, the standard sizes are displayed for that type only. I'd love to name that parameter "Size" but I don't see an option to get varying Standard Sizes for different types. So, the only option would be go like "I Beam Size", "U Beam Size" and so on?

7. The sweetest one :)

I'm going to make some combined beams which would typically consist from I beam and 1 or 2 L beams (attached to web of I beam). Besides, L beams with exact same parameters are going to be also single beams. Any ideas on this? Subroutine for L beams which is going to be called as necessary?

I attach my current version of plug-in.

Edited by Yancka

Share this post


Link to post
Is there a possibility to have ()- or probably other special symbols in parameters name?

I believe you can use the Underscore character "_" (Shift-Minus) in parameter names.

Raymond

Share this post


Link to post

use pastebin.com or post the a text file of code.

A trick I use for this type of tool.

Define each profile that you might extrude as its own sub routine.

Ie

PROCEDURE DrawASquare;

PROCEDURE DrawACircle;

Then Create a selector Procedure

ie

Procedure DrawProfile;

Begin;

If pPopup='Square' THEN DrawASquare;

If pPopup='Circle' THEN DrawACircle;

End;

Finally to draw your extrude

Procedure MakeExtured;

Begin;

BeginXtrude(0,pLinelength);

DrawProfile; {This uses logic to select which profile to be drawn to be extruded.

EndXtrude;

End;

Share this post


Link to post

I have re-worked most of my code. Few more questions.

1. Is it possible to set text object within my plugin always to be with Fill Style "None"? So that text has it's owns graphic attributes, meantime the rest of plugin 2D objects having plug-in's graphic attributes?

2. I have a text object and a leader. Leader is drawn from center of text object (just realized I have to fix text justification always to be center h and v, it appeared to be working fine because my default text justification settings were center/center) to midpoint of beam length. How to create an offset so that leader line starts not at center of the text but at the point where would be intersection of leader line as it is now and border of text object? Something like MoveTo(Direction X and Y from current pen position, Distance)? I tried to achieve it by using trigonometry but there obviously is an error. That part in my code is commented out.

3. How to make a combined beam? For example, I make Combined Beam from I beam and L beam. This Combined beam is labeled SB-7. Meantime in schedule I see data like this:

Nr._______Type_______________Height h

SB-7_____Combined Beam_____250

SB-7.1___I-Beam______________250

SB-7.2___L-Beam_____________110

Is it possible to insert plug-in into itself? Guess not... So, should I create separate plugin for combining beams? With what function/procedure do I insert plug-in into another plug-in?

Here's my code as it is today:

{3D Steel Beam; V1.4; written by Janis Prodnieks}
PROCEDURE SteelBeam;
VAR
BeamLength, ItemElevation, BeamHeight, BeamWidth, WebThickness, FlangeThickness, FiletRadius, FiletRadius2, BeamDiameter, TempReal :REAL;
DocumentTextStyle :INTEGER;
ExtrHnd, PluginHandle, TextHandle :HANDLE;
ItemNumber, BeamType :STRING;
{---- ---- ---- ---- ---- ---- PROFILE PROCEDURES ---- ---- ---- ---- ---- ----}
PROCEDURE IBeamProfile(h,b,s,t,R1 : REAL);
BEGIN
BeginPoly;
	AddPoint(-b/2,0);
	AddPoint(b/2,0);
	AddPoint(b/2,-t);
	AddPoint(s/2+R1,-t);
	ArcTo(s/2,-t,R1);
	AddPoint(s/2,-h+t+R1);
	ArcTo(s/2,-h+t,R1);
	AddPoint(b/2,-h+t);
	AddPoint(b/2,-h);
	AddPoint(-b/2,-h);
	AddPoint(-b/2,-h+t);
	AddPoint(-s/2-R1,-h+t);
	ArcTo(-s/2,-h+t,R1);
	AddPoint(-s/2,-t-R1);
	ArcTo(-s/2,-t,R1);
	AddPoint(-b/2,-t);
EndPoly;
END;

PROCEDURE UBeamProfile(h,b,s,t,R1,r2 : REAL);
BEGIN
BeginPoly;
	AddPoint(-b/2,0);
	AddPoint(b/2,0);
	AddPoint(b/2,-t+r2);
	ArcTo(b/2,-t,r2);
	AddPoint(-b/2+s+R1,-t);
	ArcTo(-b/2+s,-t,R1);
	AddPoint(-b/2+s,-h+t+R1);
	ArcTo(-b/2+s,-h+t,R1);
	AddPoint(b/2-r2,-h+t);
	ArcTo(b/2,-h+t,r2);
	AddPoint(b/2,-h+t-r2);
	AddPoint(b/2,-h);
	AddPoint(-b/2,-h);
EndPoly;
END;


PROCEDURE LBeamProfile(h,b,t,R1,r2 : REAL);
BEGIN
BeginPoly;
	AddPoint(-b/2,0);
	AddPoint(-b/2,-h);
	AddPoint(b/2,-h);
	AddPoint(b/2,-h+t-r2);
	ArcTo(b/2,-h+t,r2);
	AddPoint(-b/2+t+R1,-h+t);
	ArcTo(-b/2+t,-h+t,R1);
	AddPoint(-b/2+t,-r2);
	ArcTo(-b/2+t,0,r2);
EndPoly;
END;


PROCEDURE RectBeamProfile(h,b,s: REAL);
VAR
OuterPolyH, HolePolyTemplateH: HANDLE;
R1: REAL;
BEGIN
R1:=2.5*s;
IF s<6 THEN R1:=2*s;
IF s>10 THEN R1:=3*s;
BeginPoly;
	AddPoint(-b/2+R1+s,0);
	AddPoint(b/2-R1-s,0);
	ArcTo(b/2,0,R1+s);
	AddPoint(b/2,-R1-s);
	AddPoint(b/2,-h+R1+s);
	ArcTo(b/2,-h,R1+s);
	AddPoint(b/2-R1-s,-h);
	AddPoint(-b/2+R1+s,-h);
	ArcTo(-b/2,-h,R1+s);
	AddPoint(-b/2,-h+R1+s);
	AddPoint(-b/2,-R1-s);
	ArcTo(-b/2,0,R1+s);
EndPoly;
OuterPolyH:=LNewObj;
BeginPoly;
	AddPoint(-b/2+R1+s,-s);
	AddPoint(b/2-R1-s,-s);
	ArcTo(b/2-s,-s,R1);
	AddPoint(b/2-s,-R1-s);
	AddPoint(b/2-s,-h+R1+s);
	ArcTo(b/2-s,-h+s,R1);
	AddPoint(b/2-R1-s,-h+s);
	AddPoint(-b/2+R1+s,-h+s);
	ArcTo(-b/2+s,-h+s,R1);
	AddPoint(-b/2+s,-h+R1+s);
	AddPoint(-b/2+s,-R1-s);
	ArcTo(-b/2+s,-s,R1);
EndPoly;
HolePolyTemplateH:=LNewObj;
IF AddHole(OuterPolyH,HolePolyTemplateH) THEN DelObject (HolePolyTemplateH);
END;


PROCEDURE RoundBeamProfile(D,t: REAL);
VAR
OuterPolyH, HolePolyTemplateH: HANDLE;
BEGIN
Oval(-D/2,0,D/2,-D);
OuterPolyH:=LNewObj;
Oval(-D/2+t,0-t,D/2-t,-D+t);
HolePolyTemplateH:=LNewObj;
IF AddHole(OuterPolyH,HolePolyTemplateH) THEN DelObject (HolePolyTemplateH);
END;
{---- ---- ---- ---- ---- ---- PLUG-IN SPECIFIC OTHER SUBS ---- ---- ---- ---- ---- ----}
PROCEDURE SetInitialParameterVisibility;
BEGIN
SetParameterVisibility(PluginHandle,'I Beam Size',false);
SetParameterVisibility(PluginHandle,'U Beam Size',false);
SetParameterVisibility(PluginHandle,'L Beam Size E',false);
SetParameterVisibility(PluginHandle,'L Beam Size NE',false);
SetParameterVisibility(PluginHandle,'Sq Beam Size',false);
SetParameterVisibility(PluginHandle,'Rect Beam Size',false);
SetParameterVisibility(PluginHandle,'Round Beam Size',false);
SetParameterVisibility(PluginHandle,'Height h',false);
SetParameterVisibility(PluginHandle,'Width b',false);
SetParameterVisibility(PluginHandle,'Web Thickness s',false);
SetParameterVisibility(PluginHandle,'Flange Thickness t',false);
SetParameterVisibility(PluginHandle,'Radius R',false);
SetParameterVisibility(PluginHandle,'Radius  r',false);
SetParameterVisibility(PluginHandle,'Diameter D',false);
SetParameterVisibility(PluginHandle,'Flip h and b',false);
END;


PROCEDURE SetInitialVariables;
BEGIN
ClosePoly;

PluginHandle:=FSactLayer;
ItemNumber:= PNumber;

BeamLength:= PLineLength;
ItemElevation:= PTop_Elevation;
BeamHeight:= PHeight_h;
BeamWidth:= PWidth_b;
WebThickness:= PWeb_Thickness_s;
FlangeThickness:= PFlange_Thickness_t;
FiletRadius:= PRadius_R;
FiletRadius2:= PRadius__r;
BeamDiameter:=PDiameter_D;
END;


PROCEDURE SetStandardSizeGeneralVisibilities;
BEGIN
EnableParameter(PluginHandle,'Height h',false);
EnableParameter(PluginHandle,'Width b',false);
EnableParameter(PluginHandle,'Web Thickness s',false);
EnableParameter(PluginHandle,'Flange Thickness t',false);
EnableParameter(PluginHandle,'Radius R',false);
EnableParameter(PluginHandle,'Radius  r',false);
EnableParameter(PluginHandle,'Diameter D',false);
END;


PROCEDURE SetCustomSizeGeneralVisibilities;
BEGIN
EnableParameter(PluginHandle,'I Beam Size',false);
EnableParameter(PluginHandle,'U Beam Size',false);
EnableParameter(PluginHandle,'L Beam Size E',false);
EnableParameter(PluginHandle,'L Beam Size NE',false);
EnableParameter(PluginHandle,'Sq Beam Size',false);
EnableParameter(PluginHandle,'Rect Beam Size',false);
EnableParameter(PluginHandle,'Round Beam Size',false);
END;
{---- ---- ---- ---- ---- ---- TYPE SPECIFIC VISIBILITY SUBS ---- ---- ---- ---- ---- ----}
PROCEDURE SetIBeamVisibilities;
BEGIN
SetParameterVisibility(PluginHandle,'I Beam Size',true);
SetParameterVisibility(PluginHandle,'Height h',true);
SetParameterVisibility(PluginHandle,'Width b',true);
SetParameterVisibility(PluginHandle,'Web Thickness s',true);
SetParameterVisibility(PluginHandle,'Flange Thickness t',true);
SetParameterVisibility(PluginHandle,'Radius R',true);
EnableParameter(PluginHandle,'Profile side LEFT',false);
END;


PROCEDURE SetUBeamVisibilities;
BEGIN
SetParameterVisibility(PluginHandle,'U Beam Size',true);
SetParameterVisibility(PluginHandle,'Height h',true);
SetParameterVisibility(PluginHandle,'Width b',true);
SetParameterVisibility(PluginHandle,'Web Thickness s',true);
SetParameterVisibility(PluginHandle,'Flange Thickness t',true);
SetParameterVisibility(PluginHandle,'Radius R',true);
SetParameterVisibility(PluginHandle,'Radius  r',true);
END;


PROCEDURE SetLBeamEqualVisibilities;
BEGIN
SetParameterVisibility(PluginHandle,'L Beam Size E',true);
SetParameterVisibility(PluginHandle,'Profile side LEFT',true);
SetParameterVisibility(PluginHandle,'Width b',true);
SetParameterVisibility(PluginHandle,'Flange Thickness t',true);
SetParameterVisibility(PluginHandle,'Radius R',true);
SetParameterVisibility(PluginHandle,'Radius  r',true);
END;


PROCEDURE SetLBeamNonEqualVisibilities;
BEGIN
SetParameterVisibility(PluginHandle,'L Beam Size NE',true);
SetParameterVisibility(PluginHandle,'Profile side LEFT',true);
SetParameterVisibility(PluginHandle,'Height h',true);
SetParameterVisibility(PluginHandle,'Width b',true);
SetParameterVisibility(PluginHandle,'Flange Thickness t',true);
SetParameterVisibility(PluginHandle,'Radius R',true);
SetParameterVisibility(PluginHandle,'Radius  r',true);
SetParameterVisibility(PluginHandle,'Flip h and b',true);
END;


PROCEDURE SetSquaredBeamVisibilities;
BEGIN
SetParameterVisibility(PluginHandle,'Sq Beam Size',true);
SetParameterVisibility(PluginHandle,'Width b',true);
SetParameterVisibility(PluginHandle,'Web Thickness s',true);
EnableParameter(PluginHandle,'Profile side LEFT',false);
END;


PROCEDURE SetRectangularBeamVisibilities;
BEGIN
SetParameterVisibility(PluginHandle,'Rect Beam Size',true);
SetParameterVisibility(PluginHandle,'Height h',true);
SetParameterVisibility(PluginHandle,'Width b',true);
SetParameterVisibility(PluginHandle,'Web Thickness s',true);
EnableParameter(PluginHandle,'Profile side LEFT',false);
END;

PROCEDURE SetRoundBeamVisibilities;
BEGIN
SetParameterVisibility(PluginHandle,'Round Beam Size',true);
SetParameterVisibility(PluginHandle,'Diameter D',true);
SetParameterVisibility(PluginHandle,'Flange Thickness t',true);
EnableParameter(PluginHandle,'Profile side LEFT',false);
END;

{---- ---- ---- ---- ---- ---- TYPE SPECIFIC STANDARD SIZE SUBS ---- ---- ---- ---- ---- ----}
PROCEDURE SetIBeamStandardSize;
BEGIN
IF PI_Beam_Size='10B1'THEN BEGIN BeamHeight:=100; BeamWidth:=55; WebThickness:=4.1; FlangeThickness:= 5.7; FiletRadius:=7; END;
IF PI_Beam_Size='16B1'THEN BEGIN BeamHeight:=157; BeamWidth:=82; WebThickness:=4; FlangeThickness:= 5.9; FiletRadius:=9; END;
END;


PROCEDURE SetUBeamStandardSize;
BEGIN
IF PU_Beam_Size='5P'THEN BEGIN BeamHeight:=50; BeamWidth:=32; WebThickness:=4.4; FlangeThickness:=7; FiletRadius:=6; FiletRadius2:=3.5; END;
IF PU_Beam_Size='12P'THEN BEGIN BeamHeight:=120; BeamWidth:=52; WebThickness:=4.8; FlangeThickness:=7.8; FiletRadius:=7.5; FiletRadius2:=4.5; END;
IF PU_Beam_Size='20P'THEN BEGIN BeamHeight:=200; BeamWidth:=76; WebThickness:=5.2; FlangeThickness:=9; FiletRadius:=9.5; FiletRadius2:=5.5; END;
END;


PROCEDURE SetLBeamEqualStandardSize;
BEGIN
IF PL_Beam_size_e='20x3'THEN BEGIN BeamWidth:=20; FlangeThickness:=3; FiletRadius:=3.5; FiletRadius2:=1.2; END;
IF PL_Beam_size_e='50x4'THEN BEGIN BeamWidth:=50; FlangeThickness:=4; FiletRadius:=5.5; FiletRadius2:=1.8; END;
IF PL_Beam_size_e='70x7'THEN BEGIN BeamWidth:=70; FlangeThickness:=7; FiletRadius:=8; FiletRadius2:=2.7; END;
END;


PROCEDURE SetLBeamNonEqualStandardSize;
BEGIN
IF PL_Beam_size_ne='40x25x3'THEN BEGIN BeamHeight:=40; BeamWidth:=25; FlangeThickness:=3; FiletRadius:=4; FiletRadius2:=1.3; END;
IF PL_Beam_size_ne='63x40x8'THEN BEGIN BeamHeight:=63; BeamWidth:=40; FlangeThickness:=8; FiletRadius:=7; FiletRadius2:=2.3; END;
END;


PROCEDURE SetSquaredBeamStandardSize;
BEGIN
IF PSq_Beam_Size='50x5'THEN BEGIN BeamWidth:=50; WebThickness:=5; FiletRadius:=2.5; END;
IF PSq_Beam_Size='80x6'THEN BEGIN BeamWidth:=80; WebThickness:=6; FiletRadius:=2.5; END;
END;


PROCEDURE SetRectangularBeamStandardSize;
BEGIN
IF PRect_Beam_Size='100x60x6'THEN BEGIN BeamHeight:=100; BeamWidth:=60; WebThickness:=6; END;
IF PRect_Beam_Size='260x140x12.5'THEN BEGIN BeamHeight:=260; BeamWidth:=140; WebThickness:=12.5; END;
END;

PROCEDURE SetRoundBeamStandardSize;
BEGIN
IF PRound_Beam_Size='76x2.5' THEN BEGIN BeamDiameter:=76; FlangeThickness:=2.5; END;
IF PRound_Beam_Size='101.6x2.5' THEN BEGIN BeamDiameter:=101.6; FlangeThickness:=2.5; END;
END;

{---- ---- ---- ---- ---- ---- 2D OBJECT SUBS ---- ---- ---- ---- ---- ----}
PROCEDURE Create2DRectangle;
BEGIN
IF PBeam_Type='Round Beam' THEN BeamWidth:=BeamDiameter;
MoveTo(0,-BeamWidth/2);
Rect(BeamWidth,#90,BeamLength,#0);
END;

PROCEDURE Create2DRectangleWithLine;
BEGIN
IF PFlip_h_and_b=true THEN
	BEGIN
		TempReal:=BeamHeight;
		BeamHeight:=BeamWidth;
		BeamWidth:=TempReal;
	END;
Create2DRectangle;
MoveTo(0,-BeamWidth/2+FlangeThickness);
LineTo(BeamLength,-BeamWidth/2+FlangeThickness);
IF PProfile_Side_LEFT=true THEN FlipVer;
END;

PROCEDURE CreateTextContainingBeamInfo;

BEGIN
IF PBeam_Type='Round Beam' THEN BeamHeight:=BeamDiameter;
IF PControlPoint01X=0 THEN
	BEGIN
		SetRField(PluginHandle,'3D Steel Beam','ControlPoint01X','1500');
	END;

DocumentTextStyle:=GetPrefInt(58);

SetPrefInt(58,0);


TextOrigin(PControlPoint01X, PControlPoint01Y);
CreateText(Concat(ItemNumber,CHR(13),'L-',Num2Str(0,BeamLength),CHR(13),Num2Str(3,(ItemElevation-BeamHeight)/1000)));
TextHandle:=lnewobj;
SetTextSize(lnewobj,0,Len(ItemNumber),15);
SetTextStyle(lnewobj,0,Len(ItemNumber),3);
SetTextSize(lnewobj,Len(ItemNumber),Len(Num2Str(0,BeamLength))+3,6);
SetTextStyle(lnewobj,Len(ItemNumber),Len(Num2Str(0,BeamLength))+3,3);
SetTextSize(lnewobj,Len(ItemNumber)+Len(Num2Str(0,BeamLength))+4,Len(Num2Str(3,(ItemElevation-BeamHeight)/1000)),10);
SetTextStyle(lnewobj,Len(ItemNumber)+Len(Num2Str(0,BeamLength))+4,Len(Num2Str(3,(ItemElevation-BeamHeight)/1000)),7);
SetTextFont(lnewobj,0,Len(ItemNumber)+Len(Num2Str(0,BeamLength))+4+Len(Num2Str(3,(ItemElevation-BeamHeight)/1000)),GetFontID('Bank Gothic'));
SetTextLeading(lnewobj,8);
{SetVectorFill(TextHandle,'None');}

SetPrefInt(58,DocumentTextStyle);
END;


PROCEDURE DrawLeaderLine;
VAR
a,b,c, Angle: REAL;
BEGIN
IF PDraw_Leader=true THEN
	BEGIN
		MoveTo(PControlPoint01X, PControlPoint01Y);
		LineTo(BeamLength/2,0);
		SetObjArrow(lnewobj,3,0.02,0,false,true);

		{c:=Sqrt(sqr(PControlPoint01X-BeamLength/2)+sqr(PControlPoint01Y));
		Angle:=ArcSin(PControlPoint01Y/c);
		c:=c-1000;
		b:=Sin(Angle)*c;
		a:=ArcCos((PControlPoint01Y+BeamLength/2)/c);}

		{Angle:=-Rad2Deg(ArcSin(PControlPoint01Y/Sqrt(sqr(PControlPoint01X-BeamLength/2)+sqr(PControlPoint01Y))));
		MoveTo(PControlPoint01X, PControlPoint01Y);
		AngleVar;
		MoveTo(1000, #Angle);
		Absolute;}
	END;
END;
{---- ---- ---- ---- ---- ---- 3D OBJECT SUBS ---- ---- ---- ---- ---- ----}
PROCEDURE CreateExtrudeProfile;
BEGIN
IF PBeam_Type='I-Beam' THEN IBeamProfile(BeamHeight,BeamWidth,WebThickness,FlangeThickness,FiletRadius);
IF PBeam_Type='U-Beam' THEN UBeamProfile(BeamHeight,BeamWidth,WebThickness,FlangeThickness,FiletRadius,FiletRadius2);
IF PBeam_Type='L-Beam (equal)' THEN LBeamProfile(BeamWidth,BeamWidth,FlangeThickness,FiletRadius,FiletRadius2);
IF PBeam_Type='L-Beam (non-equal)' THEN LBeamProfile(BeamHeight,BeamWidth,FlangeThickness,FiletRadius,FiletRadius2);
IF PBeam_Type='Squared Beam' THEN RectBeamProfile(BeamWidth,BeamWidth,WebThickness);
IF PBeam_Type='Rectangular Beam' THEN RectBeamProfile(BeamHeight,BeamWidth,WebThickness);
IF PBeam_Type='Round Beam' THEN RoundBeamProfile(BeamDiameter,FlangeThickness);
END;
{---- ---- ---- ---- ---- ---- PLUG-IN SPECIFIC GENERAL SUBS ---- ---- ---- ---- ---- ----}
PROCEDURE SetInitialInfo;
BEGIN
SetInitialVariables;
SetInitialParameterVisibility;
END;

PROCEDURE SetCustomOrStandardSizeGeneralSettings;
BEGIN
IF PCustom_Beam=false THEN SetStandardSizeGeneralVisibilities ELSE SetCustomSizeGeneralVisibilities;
IF PCustom_Beam=false THEN
BEGIN
	IF PBeam_Type='I-Beam' THEN SetIBeamStandardSize;
	IF PBeam_Type='U-Beam' THEN SetUBeamStandardSize;
	IF PBeam_Type='L-Beam (equal)' THEN SetLBeamEqualStandardSize;
	IF PBeam_Type='L-Beam (non-equal)' THEN SetLBeamNonEqualStandardSize;
	IF PBeam_Type='Squared Beam' THEN SetSquaredBeamStandardSize;
	IF PBeam_Type='Rectangular Beam' THEN SetRectangularBeamStandardSize;
	IF PBeam_Type='Round Beam' THEN SetRoundBeamStandardSize;

	SetRField(PluginHandle,'3D Steel Beam','Height h',Num2Str(0,BeamHeight));
	SetRField(PluginHandle,'3D Steel Beam','Width b',Num2Str(0,BeamWidth));
	SetRField(PluginHandle,'3D Steel Beam','Web Thickness s',Num2Str(1,WebThickness));
	SetRField(PluginHandle,'3D Steel Beam','Flange Thickness t',Num2Str(1,FlangeThickness));
	SetRField(PluginHandle,'3D Steel Beam','Radius R',Num2Str(1,FiletRadius));
	SetRField(PluginHandle,'3D Steel Beam','Radius  r',Num2Str(1,FiletRadius2));
	SetRField(PluginHandle,'3D Steel Beam','Diameter D',Num2Str(1,BeamDiameter));
END;
END;

PROCEDURE SetTypeSpecificVisibilities;
BEGIN
IF PBeam_Type='I-Beam' THEN SetIBeamVisibilities;
IF PBeam_Type='U-Beam' THEN SetUBeamVisibilities;
IF PBeam_Type='L-Beam (equal)' THEN SetLBeamEqualVisibilities;
IF PBeam_Type='L-Beam (non-equal)' THEN SetLBeamNonEqualVisibilities;
IF PBeam_Type='Squared Beam' THEN SetSquaredBeamVisibilities;
IF PBeam_Type='Rectangular Beam' THEN SetRectangularBeamVisibilities;
IF PBeam_Type='Round Beam' THEN SetRoundBeamVisibilities;
END;

PROCEDURE Create2DObjects;
BEGIN
IF PBeam_Type='I-Beam' THEN Create2DRectangle;
IF PBeam_Type='U-Beam' THEN Create2DRectangle;
IF PBeam_Type='L-Beam (equal)' THEN Create2DRectangleWithLine;
IF PBeam_Type='L-Beam (non-equal)' THEN Create2DRectangleWithLine;
IF PBeam_Type='Squared Beam' THEN Create2DRectangle;
IF PBeam_Type='Rectangular Beam' THEN Create2DRectangle;
IF PBeam_Type='Round Beam' THEN Create2DRectangle;
CreateTextContainingBeamInfo;
DrawLeaderLine;
END;

PROCEDURE CreateExtrude;
BEGIN
BeginXtrd(0,BeamLength);
	CreateExtrudeProfile;
	IF PProfile_Side_LEFT=true THEN FlipHor;
EndXtrd;
ExtrHnd:=LNewObj;
SET3DRot(ExtrHnd, 90, 0, 90, 0, 0, 0);
Move3DObj(ExtrHnd,0,0, ItemElevation);
END;
{---- ---- ---- ---- ---- ---- ---- ---- ---- ---- MAIN CODE ---- ---- ---- ---- ---- ---- ---- ---- ---- ----}
BEGIN
SetInitialInfo;
SetCustomOrStandardSizeGeneralSettings;
SetTypeSpecificVisibilities;
Create2DObjects;
CreateExtrude;
END;
Run(SteelBeam);

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×