Jump to content
Sign in to follow this  
Pat Stanford

Custom Tool Setting Prototype

Recommended Posts

The following script is an example of how to set the parameters of a PIO and then Call that tool in a custom script. Posted here and linked to another thread.

{Begin Script}

Procedure Tool_Setting_Prototype;

{ Constructed as a prototype for creating custom tools in VW2008 }

{ This particual instance sets the active class and layer, }

{ Sets all attributes to ByClass, and sets several default parameters of the PIO }

{ And sets the active tool to the Repetitive Unit tool }

{Jul 20, 2008}

{? 2008, Coviana, Inc - Pat Stanford pat@coviana.com}

{Licensed under the GNU Lesser General Public License}

{The GNU Lesser General Public License is a Free Software license. Like any Free Software license, it grants to you the four following freedoms: }

{ The freedom to run the program for any purpose. }

{ The freedom to study how the program works and adapt it to your needs. }

{ The freedom to redistribute copies so you can help your neighbor. }

{ The freedom to improve the program and release your improvements to the public, so that the whole community benefits. }

{ The full version is viewable at }

VAR

Name:STRING;

Result:BOOLEAN;

BEGIN

{** Set the Active Layer and Class **}

NameClass('None'); {Set this to the desired class}

Layer('Design Layer-1'); {Set this to the desired layer}

{** Set Attributes to ByClass **}

Result:=FFillColorByClass;

FPatByClass;

FillColorByClass;

LSByClass;

LWByClass;

MarkerByClass;

PenColorByClass;

SetDefaultOpacityByClass;

{** Set Some of the PIO Parameters of the Repetitive Unit tool **}

SetRField(GetObject('Repetitive Unit'),'Repetitive Unit','__SymbolName','Wood 3x6 T&G');

SetRField(GetObject('Repetitive Unit'),'Repetitive Unit','__SymbolFolder','Flooring - Decking');

SetRField(GetObject('Repetitive Unit'),'Repetitive Unit','Pitch','144');

{** Set the Active Tool to Repetitive Unit **}

Result:=SetToolByName('Repetitive Unit'); {SetToolByName is new in VW2008}

END;

Run(Tool_Setting_Prototype);

{End Script}

Pat

Share this post


Link to post

Pat, thanks for helping out with the script. Over the weekend I had success making the script work with the same syntax you posted except for the:

Result:=SetToolByName('Repetitive Unit');

This is the script:

Procedure CustTool;

VAR

Name:STRING;

Result:BOOLEAN;

BEGIN

(*PushAttrs;*)

PenColorByClass;

MarkerByClass;

FPatByClass;

FillColorByClass;

NameClass('Plumbing-Gas');

LSByClass;

LWByClass;

Layer('Mod-Site-Civil');

SetRField(GetObject('Repetitive Unit'),'Repetitive Unit','Pitch','192');

SetRField(GetObject('Repetitive Unit'),'Repetitive Unit','__SymbolFolder','Miscellaneous');

SetRField(GetObject('Repetitive Unit'),'Repetitive Unit','__SymbolName','Site-Gas');

CallTool(-235);

DSelectAll;

(*PopAttrs;*)

END;

The only difference here is the calltool(-235); command.

By the way, why set the "Result:" variable with the command?

Thanks for helping me on this, it is a huge help to have this. I've duplicated this script many times for numerous line styles for site plans.

Share this post


Link to post

On my machine CallTool(-235) is not the Repetitive Unit tool. Watch out as you move to other machines. The SetToolByName allows you to use "VectorScript Tools" that either you or someone else has created that don't have tool numbers.

The Result:= is required because the SetToolByName returns a boolean value telling if the command was successful or not. Personally, I think it is stupid, but it is required. Many of the VS commands now require this kind of syntax.

Glad it is working for you.

Regards,

Pat

Share this post


Link to post

Pat, what is the vectorscript command equivalent to the context menu "edit" command?

I'm trying to enter a text box after selected, run a command to edit the text to entry the text box, select the text and copy it to the clipboard.

Regards

Share this post


Link to post

I don't think there is a way to enter Text Edit Mode from a Vectorscript.

Do you need to preserve the formatting or just get the text? What exactly are you trying to do?

Pat

Share this post


Link to post

Hello Pat,

I have a number of standard CAD details from another CAD application I'm trying to expedite into VW. This requires updating many of the callout text boxes. If I could write a script that would do the following:

1. Open the selected text box

2. Select all the text

3. Copy all the text to the clipboard.

4. Delete the old text box

5. Select the VW callout tool so that all I have to do is place the callout,paste the text, and edit it as needed.

I'm currently doing all that just want to speed it up a bit.

Regards.

Share this post


Link to post

Daryl,

Try this out. You probably need to adjust it to set the other callout parameters to what you need.

Create a Text box and leave it selected. Run the script. You will now have a callout object with the arrow starting at the same point as the original text origin.

Procedure CallOutFromText;

{ Simple routine to create a callout object from a text object}

{Jul 22, 2008}

{? 2008, Coviana, Inc - Pat Stanford pat@coviana.com}

{Licensed under the GNU Lesser General Public License}

{The GNU Lesser General Public License is a Free Software license. }

{Like any Free Software license, it grants to you the four following freedoms: }

{ The freedom to run the program for any purpose. }

{ The freedom to study how the program works and adapt it to your needs. }

{ The freedom to redistribute copies so you can help your neighbor. }

{ The freedom to improve the program and release your improvements to the public, }

{ so that the whole community benefits. }

{ The full version is viewable at }

Var C1:DynArray of Char;

H1:Handle;

X1,Y1,R1:Real;

B1:Boolean;

Begin

C1:=GetText(FSActLayer);

GetTextOrientation(FSActLayer,X1,Y1,R1,B1);

DelObject(FSActLayer);

DSelectAll;

H1:=CreateCustomObjectN('Callout', X1, Y1, 0, False);

SetRField(H1,'Callout','Text',C1);

End;

Run(CallOutFromText);

Pat

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.

×