Taproot Posted September 13, 2008 Share Posted September 13, 2008 I've been working with NNA's example files for a wee bit and have yet to find the right chemistry with Vectorscript. I'm trying to create a tool or menu command that will allow me to set the active class and layer to that of an object by selecting it. Intuitively, I know this is only a few lines of code, can anyone enlighten me on how to do it? Many thanks, Quote Link to comment
gmm18 Posted September 13, 2008 Share Posted September 13, 2008 Just right-click an object, there you can set Active Class & Layer to that object's. Quote Link to comment
Taproot Posted September 13, 2008 Author Share Posted September 13, 2008 GMM, Thoughtful - yes, that is my current process. I often want to jump to both the object class and layer in one step and right clicking on each object twice is slow. This seems like a perfect opportunity for Vectorscript (to combine the two). Quote Link to comment
Guest Frank Brault Posted September 13, 2008 Share Posted September 13, 2008 This task is possible without any VectorScript; Control/Right Click on object; Activate Class and Activate Layer commands appear in the context menu. Perhaps you are actually interested in learning VectorScript. The VectorScript pseudo code for this would be: Set the active class or layer to the class or layer of the selected or picked object It's one line of code if you only want one permutation of the possible variations; Here is the code to set the active class to the class of the selected object if the object is on the active layer: NameClass(GetClass(FSActLayer)); Reading backwards: FSActlayer returns a handle reference to the First Selected object in the ACTive LAYER; GetClass() returns the name of the object's class as a text string; NameClass() creates a new class if the class doesn't exist and then sets the active class to the class named in the string. It is considerably more work if you want to get an object that is not on the active layer or if the layer or class options prevent the user from selecting the object. If you want an interface with preferences or settings and if you want your procedure to remember the settings across uses it is yet more work. hth, Quote Link to comment
maarten. Posted September 14, 2008 Share Posted September 14, 2008 This should do the trick. There are other ways of doing it, but as Frank said, getting the layer of the selected object is not that easy. PROCEDURE ActivateLayerAndClass; VAR pt : POINT; h : HANDLE; BEGIN GetPt(pt.x,pt.y); h:=PickObject(pt.x,pt.y); IF h<>NIL THEN BEGIN NameClass(GetClass(h)); Layer (GetLName (GetLayer(h))); END; END; RUN(ActivateLayerAndClass); It lets you pick an object and then will set the class and layer of that object active. Quote Link to comment
Guest Frank Brault Posted September 14, 2008 Share Posted September 14, 2008 After reading Maarten's post I thought of another approach. Since the work is already being accomplished by menu commands, why not create a script that calls the two existing commands one after the other? Create a new VectorScript menu and paste the lines below: Procedure ActivateLayerAndClass2; Begin DoMenuTextByName('Activate Class', 0); DoMenuTextByName('Activate Layer', 0); Redraw; End; Run(ActivateLayerAndClass2); Add your new command to the document and object context menus of your workspace with the workspace editor. Standard disclaimer: I haven't tested this script at all - Use at your own risk. Quote Link to comment
maarten. Posted September 15, 2008 Share Posted September 15, 2008 It seems like the "Activate Layer" command isn't standaard in the Dutch workspace so therefor i had no idea of its excistence... Thanks for the info Frank, i learn something new every day . Quote Link to comment
Taproot Posted September 15, 2008 Author Share Posted September 15, 2008 Frank and Maarten - Brilliant! Both of your approaches are sound and easy to implement (even for me as a relative script novice). I went with Frank's approach, because it flowed right into my context menu (beside Activate Class and Activate Layer). For any other script beginners wanting to implement this, this is how I did it: Copy Frank (or Maarten's) script out of this thread, Tools->Scripts->Plug-in Editor Create New Command (and name it): "Activate L+C" (or any name you wish less than 20 characters) Select "Script" button Paste text from this thread Save Hit "Done" You can now go into your Workspace Editor and place it in any menu you want, assign a keyboard shortcut, etc. Many thanks! Quote Link to comment
Taproot Posted May 29, 2020 Author Share Posted May 29, 2020 (edited) Has it really been 12 years since the above post (incredulous voice)? I recently needed to revise the plugins that I created from this thread and thought that they might be useful to some of you, so I'm going to include them here. These are all point and shoot tools. Clicking on an object carries out an action. Listed in order of appearance (icons below) TA_Set To Active Class - In the event that an object is mis-classed. This tool lets you click on the object and move it to the active class. TA_Class Hide - Sometimes a class is in my way and I just want to hide it from view. Clicking on an object will hide its class. TA_Activate L+C-Tool - I jump around a lot in the drafting process. When clicking on an object, this tool makes the active layer and class that of the object. I've set this one to a standard hot key in the workspace editor (makes it really convenient to use). Use at your own risk ... but works fine on my 2020 mac setup and as they are über simple and should work on most any configuration of VW. To use: Download, move into your plugins folder (start or restart VW) and then add them to your workspace. TA_Set To Active Class.vst TA_Class Hide.vst TA_Activate L+C-Tool.vst Edited May 29, 2020 by Taproot Quote Link to comment
Recommended Posts
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.