beanus 8 Posted March 30 is it possible to create a script so that when I use the callout tool it's automatically inserted into a class called "notes" if so can someone do this for me, I've tried looking at the Marionette tool just can't get my head around the way it works. 😱 Quote Share this post Link to post
Pat Stanford 1,630 Posted March 30 This script will set the class to what is inside the quotes of Const MyClass='None'. Change the None to whatever class name you want.  It will not place just the callout in that class, but will change the active class of the drawing to the callout class.  I may be able to work around that later (or someone else may pop up first).  Not a Marionette solution, but quick and dirty.  Procedure ClassedCallout; {March 30, 2021} {©2021 Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {No Warranty Expressed of Implied. Use at your own risk.} Const MyClass='None'; Var S1: String; B1: Boolean; Begin S1:=ActiveClass; NameClass(MyClass); B1:=CallToolByName('Callout Tool'); End; Run(ClassedCallout);  Quote Share this post Link to post
Jesse Cogswell 70 Posted March 31 Another possible solution is this script, which will place all Callout objects in the drawing into the class specified by the MyClass constant similar to Pat's script above. You can run this before publishing to catch any callouts that got missed.  PROCEDURE SetCalloutClass; {Sets all Callout objects in drawing to class set by MyClass variable} CONST MyClass = 'Notes'; PROCEDURE SetTheClass(h:HANDLE); BEGIN SetClass(h,MyClass); END; BEGIN ForEachObject(SetTheClass,(INSYMBOL & INOBJECT & INVIEWPORT & (R IN ['Callout']))); END; Run(SetCalloutClass);  To add this to a drawing, in the Resource Manager, right-click and select New Resource. Select Script from the menu. If this is the first script in the drawing, it will ask you to specify a Script Palette, this can be whatever you want to call it. "Macros" for example. Then name the script. I named mine "Set Callout Class." A text editor window should open up. Make sure that the language specified by the drop-down is set to "Vectorscript" and copy and paste the code in and click OK at the bottom of the dialog. This should now appear in a floating palette and can be run by double-clicking the named script.  If you want to make this a more permanent part of your Vectorworks application, you can change it to a menu command using the Plug-in Manager, found under the Tools menu.  Unfortunately, there isn't a way to specify a class for plug-in objects unless that plug-in object has a "Style" attached to it, which the standard Callout object does not. 2 Quote Share this post Link to post
beanus 8 Posted March 31 Thanks to you both, I'll give both a try and see how it goes. Quote Share this post Link to post
beanus 8 Posted March 31 just another thought, is not possible to make a tool that runs a macro that changes the current class to "notes" and then runs the callout tool? Quote Share this post Link to post
Jesse Cogswell 70 Posted March 31 @beanus Pat's code above could actually work beautifully for that. It is a little tricky to get it set up if you haven't done it before, but I'll list the steps below. Open up the Plug-in Manager by going to Tools - Plug-ins - Plug-in Manager Select the "Custom Plug-ins" tab Click on the "New" button at the bottom of the dialog Select either "Tool" or "Menu Command." Tool will place it in a tool set (where the Callout Tool regularly resides), Menu Command will make it a command reached through the main menu toolbar Name the tool/command. Could be something like "Notes Callout" or something like that If the script editor window doesn't launch automatically, click on the "Edit Script" button Copy and paste Pat's script into the editor and click "OK" (but do make sure you set the constant to "Notes" or whatever class you want first) Click "OK" to close the Plug-in Manager. Depending on which version of VW you are using, it might prompt you to restart VW. Open up the Workspace Editor by going to Tools - Workspaces - Edit Current Workspace Select either the Tools or Menus tab based on which option you selected earlier. In the left box, scroll down until you find the "Miscellaneous" category and expand it In the right box, find either the tool set or the menu you want the script to be under and expand it Click and drag the tool/command from the left box to the right box Click "OK" to reset your workspace You're done! A couple of things to keep in mind: if I were you, I would set it as a menu command and bind the shortcut for the Callout Tool to it. If you place it as a tool, you'll have to do an additional click to start the tool (one click to select it from the tool set, another click on the drawing to activate).  The one caveat to this is that running the tool/command will set your active class to whatever class you set. Pat's script DOES record the active class when running the tool, but I don't know if there is a way for the tool to detect when the tool is "finished" to restore to the active class, Pat might have some ideas. 2 Quote Share this post Link to post
Laura Stone 22 Posted April 1 Is there a way of making a similar tool that would move a selected object into a class (in this case Site DTM Modifiers) without changing the active class?  I am using 3D poly modifiers and it's very time consuming to scroll dow through the list each time.  Custom tool used to do things like this without any programming knowledge a long time ago.  Thanks  Laura Quote Share this post Link to post
Jesse Cogswell 70 Posted April 2 @Laura Stone That's really simple. Below is a code snippet that will move selected objects into the class set by the MyClass constant. If you put this in a script palette, you could have multiple copies set for different classes. I could see it saving a decent amount of time if you're moving things to different classes a lot, but have a lot of classes in the drawing (especially in VW2018 before they implemented searchable Class drop-downs).  PROCEDURE SetSelectedObjClass; {Sets all Callout objects in drawing to class set by MyClass variable} CONST MyClass = 'None'; VAR ActiveLayer:STRING; PROCEDURE SetTheClass(h:HANDLE); BEGIN SetClass(h,MyClass); ResetObject(h); END; BEGIN ActiveLayer:=GetLName(ActLayer); ForEachObject(SetTheClass,((SEL=TRUE) & (L=ActiveLayer))); END; Run(SetSelectedObjClass); This script does assume that you are drafting with View-Layer Options set to Show/Snap and not Show/Snap/Modify. This script will only work on selected objects on the currently active layer, preventing you from changing classes on something that is selected, but not on the active layer, therefore not "showing" as selected. If, however, you work with Show/Snap/Modify, then change the ForEachObject line to:  ForEachObject(SetTheClass,(SEL=TRUE)); Let me know if you need any help getting this script to work in your drawings. Not knowing your full use-case, I would suggest keeping it with the drawing in a script palette so that it's easy to change the class name. If you are intending to use the tool with the same class all of the time and want to bind the script to a keyboard shortcut, follow the steps listed in my last post and make this script part of your VW user folder. 1 Quote Share this post Link to post
Laura Stone 22 Posted April 2 Great,  thanks Jesse that works perfectly and will save me a whole load of time.  Just to make it a bit more complicated, when I do the change manually it gives me an option to change all attributes to the new class defaults, it that something that could be written into the script?  Laura  Quote Share this post Link to post
Jesse Cogswell 70 Posted April 2 I can absolutely add that functionality in. Quick question, so you prefer to have your attribute settings to be set By Class or to use the Use at Creation method but otherwise leave the graphic attributes as absolute? I can go to ways with this, I can add lines of code to set all the attributes of the selected items to be By Class, or I can read in the class defaults and set the graphic attributes accordingly. Quote Share this post Link to post
Laura Stone 22 Posted April 2 Hi Jesse,  Thanks very much, I would like this option please -  "add lines of code to set all the attributes of the selected items to be By Class"  I don't normally have 2D attributes by class (it is only fill and pen attributes that I need here) it's just quite handy to have the site modifiers by class, then I can see which ones I've finished.  Laura   Quote Share this post Link to post
Jesse Cogswell 70 Posted April 3 Here you go. The script will now set all attributes to be "By Class." Each line is notated with what the attribute is, so if there are attributes you don't want to set (like Marker or Line Weight), just delete those lines. If you would rather set the objects to use the defaults of the class without the "By Class" reference, let me know and I'll adjust the code.  PROCEDURE SetSelectedObjClass; {Sets all Callout objects in drawing to class set by MyClass variable} CONST MyClass = 'None'; VAR ActiveLayer:STRING; PROCEDURE SetTheClass(h:HANDLE); BEGIN SetClass(h,MyClass); {Attributes settings} SetFPatByClass(h); {Fill Pattern} SetFillColorByClass(h); {Fill Color} SetLSByClass(h); {Line Type} SetPenColorByClass(h); {Pen Color} SetLWByClass(h); {Line Weight} SetOpacityByClass(h); {Opacity} SetMarkerByClass(h); {Marker} ResetObject(h); END; BEGIN ActiveLayer:=GetLName(ActLayer); ForEachObject(SetTheClass,((SEL=TRUE) & (L=ActiveLayer))); END; Run(SetSelectedObjClass);  Quote Share this post Link to post
Laura Stone 22 Posted April 3 Jesse,  Thanks very much, that works just as I wanted it to.  Much appreciated  Laura Quote Share this post Link to post