Jump to content

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

Link to comment

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.

Link to comment

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

Link to comment

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.

Link to comment

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

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