Jump to content

current object tool


bertb

Recommended Posts

I am a new VW user (6/4/02). 3 years ago I worked in an office which used Minicad 7. Someone wrote a script: pick an object then the tool which created it, and all the object attributes-layer, class, color, pen, etc. became active. It was beautiful. Does anyone have this script?

Link to comment

It sounds like someone just did a "Custom Tool/ Attribute..." from the Organize menu. Custom Tool/ Attribute just records the items checked and then resets them when you run the script. If I'm correct, that's a no brainer. Here's an example.HTHDave----------------------------------------Procedure CustTool;VAR Name:STRING;Result:BOOLEAN;BEGIN PushAttrs;FillFore(255);FillBack(39);FillPat(1);PenFore(4);PenBack(0);PenPat(2);PenSize(40);PenPat(2);Marker(0, 0.125000, 15);

NameClass('None');Layer('Layer-1');CallTool(-203);PopAttrs;END;Run(CustTool);

Link to comment

The difference between the custom tool/attribute and the script I am looking for is custom tool will only make active one set of tool and attribute (the one's active at time of custom tool creation). A new tool needs to be created for each wall type, line, etc. The script written for minicad 7 was: run the tool (script) then pick on an object, whatever the tool and attributes of that object becomes active. The beauty is one custom tool can be used to activate plethora of different tools and attribute combinations.

Link to comment

Sounds like a great idea! I'm not an expert vscripter, but I think the logic would be straight forward while the implementation would be lengthy. For each attribute you would need a get and a set and for each tool you would need something similar.That's where things might get interesting as I don't think there is a get for how an object was created, so you would have to go by object type and decide on the appropriate tool. The simplest example would be a line...if object type is line then get line tool.

If anyone else thinks this is the way to go at it I might work on it...when I get some time.

Link to comment

If you want to set an object tool and set active attributes by clicking on an object on the screen, that can be done for all the simpler objects. ccroft has the right idea about get/set and getobject type/ set tool.

Writing the script wouldn't be too hard to write, just a bit of time. Go for it ccroft, I'll help if you get stuck.

Link to comment

The difference between the custom tool/attribute and the script I am looking for is custom tool will only make active one set of tool and attribute (the one's active at time of custom tool creation). A new tool needs to be created for each wall type, line, etc. The script written for minicad 7 was: run the tool (script) then pick on an object, whatever the tool and attributes of that object becomes active. The beauty is one custom tool can be used to activate plethora of different tools and attribute combinations.

Link to comment

This is the script written in MiniCad7 for the select current object tool. It doesn't work in Vectorworks. I am script illiterate. Can anyone help. Thanks in advance.

INTEGER;Procedure COT;

VAR X,Y,ObjPROP:REAL; h,layerHandle:HANDLE; Red,Green,Blue:LONGINT; LayerName:STRING;

BEGIN

GetPt(X,Y); h:=PickObject(X,Y);IF h<>NIL THEN BEGIN

layerHandle:=GetLayer(h); {Set Layer}layerName:=GetLName(layerHandle);layer(LayerName)

NameClass(GetClass(h)); {Set Class}

PenSize(GetLW(h)); {Set Pensize & Style}PenPat(GetLS(h));

GetFillFore(h,Red,Green,Blue);FillFore(Red,Green,Blue); {Set Fill Colors}GetFillBack(h,Red,Green,Blue);FillBack(Red,Green,Blue);

GetPenFore(h,Red,Green,Blue);PenFore(Red,Green,Blue); {Set Pen Colors}GetPenBack(h,Red,Green,Blue);PenBack(Red,Green,Blue);

h:=NIL;ENDelseEND;

RUN(COT);

Link to comment

bertb,The first word 'INTEGER' was making your code inoperable. I took a few liberties and streamlined your code, and I also changed the comments a little. I hope this makes it readable to you.

Most code is adapted from code that already works so your scripting talents will grow from practice.

Have fun,Raymond

Procedure COT;{ Make all the attributes of the selected object the active attributes }VAR X, Y :REAL; h :HANDLE; Red, Green, Blue :LONGINT;BEGIN GetPt(X, Y); h := PickObject(X, Y); IF (h <> NIL) THEN begin { Make H's layer & class active } Layer(GetLName(GetLayer(h))); NameClass(GetClass(h)); { Set Fill Pattern & Colors } FillPat(GetFPat(h)); GetFillFore(h, Red, Green, Blue); FillFore(Red, Green, Blue); GetFillBack(h, Red, Green, Blue); FillBack(Red, Green, Blue); { Set Pen's Size, Style & Colors } PenSize(GetLW(h)); PenPat(GetLS(h)); GetPenFore(h, Red, Green, Blue); PenFore(Red, Green, Blue); GetPenBack(h, Red, Green, Blue); PenBack(Red, Green, Blue); end;END;RUN(COT);

Link to comment

bertb,The first word 'INTEGER' was making your code inoperable. I took a few liberties and streamlined your code, and I also changed the comments a little. I hope this makes it readable to you.

Most code is adapted from code that already works so your scripting talents will grow from practice.

Have fun,Raymond

Procedure COT;{ Make all the attributes of the selected object the active attributes }VAR X, Y :REAL; h :HANDLE; Red, Green, Blue :LONGINT;BEGIN GetPt(X, Y); h := PickObject(X, Y); IF (h <> NIL) THEN begin { Make H's layer & class active } Layer(GetLName(GetLayer(h))); NameClass(GetClass(h)); { Set Fill Pattern & Colors } FillPat(GetFPat(h)); GetFillFore(h, Red, Green, Blue); FillFore(Red, Green, Blue); GetFillBack(h, Red, Green, Blue); FillBack(Red, Green, Blue); { Set Pen's Size, Style & Colors } PenSize(GetLW(h)); PenPat(GetLS(h)); GetPenFore(h, Red, Green, Blue); PenFore(Red, Green, Blue); GetPenBack(h, Red, Green, Blue); PenBack(Red, Green, Blue); end;END;RUN(COT);

Link to comment

quote:

Originally posted by bertb:
Can someone help set the current tool, in addition to the function of setting current attributes, to the whatever object is picked after running the script?

bertb,This is not hard either. Just add the following case statement after the PenBack command:

... PenBack(Red, Green, Blue); { Select Tool } case GetType(h) of 2: SetTool(-201); { Line } 3: SetTool(-203); { Rect } 4: SetTool(-205); { Oval } 5: SetTool(-207); { Poly } 6: SetTool(-202); { Arc } 8: SetTool(-220); { Freehand } 10: SetTool(-200); { Text } 12: SetTool(-227); { Quarter Arc } 13: SetTool(-217); { RRect } 15: SetTool(-209); { 2D Symbol } 17: SetTool(-221); { 2D Locus } 21: SetTool(-204); { PolyLine } { etc. } end;

This list is not exhaustive, by any means. You may want more tools supported than the ones I have here. Embellish away. The Tool #'s and the Object Types are in the appendix of the VectorScript Function Reference which you should already have. If not, you really should download a copy.

HTH,Raymond

[ 06-14-2002: Message edited by: MullinRJ ]

Link to comment

I have to say that this thread has made me think of a wishlist item for a version of VW. That is another mode for the 2D or 3D pointer tools, that when you clicked on an object in your drawing it not only selected everything the eydropper does class attributes etc, but also then made the tool that created it active, so you could even more quickly add to an existing drawing.

all the best

[ 06-14-2002: Message edited by: ionw ]

Link to comment

ruud,

The eyedropper tool allows you to pick up attributes and squirt them into existing objects, but does not change your current attributes settings. this custom tool does. Thanks to MullinRJ.

Can someone help set the current tool, in addition to the function of setting current attributes, to the whatever object is picked after running the script?

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