Tom W. Posted September 23, 2023 Share Posted September 23, 2023 (edited) Ok here goes... The version of the script I'm using: Procedure ViewportRename; {Badly Scripted by Michael Klaers. Chopped around by TW 22 Sept 2023} {This script will take all selected viewports and change the name of those viewports to be <Sheet Layer>/<Drawing Number> (<Drawing Title>) This version tries to force the name to appear immediately in the name field, data tab, OIP when only one VP is selected. Prior to this version the new name appeared immediately in the Nav Palette, but not in the name field.} Var VPDwgTitle,VPName,BText,VPNum, VPClass : String; h,hh: Handle; ViewportLayer: Handle; ViewportLayerString: String; Procedure RenameVP(h : HANDLE); Begin {*********** BEGIN Procedure ***********} ViewportLayer:= GetLayer(h); ViewportLayerString:= GetLName(ViewportLayer); VPClass := GetClass(h); VPDwgTitle := GetObjectVariableString(h, 1032); VPNum := GetObjectVariableString(h, 1033); ResetObject(h); SetName(h, CONCAT(ViewportLayerString,'/',VPNum,' (',VPDwgTitle,')')); SetDSelect(h); {These two commands are just here to force the new name to appear in the } SetSelect(h); {name field immediately. They can be deleted w/o consequence} End; {*********** END Procedure ***********} Begin {*********** Main Program ***********} ForEachObject(RenameVP,(((T=VIEWPORT) & (VSEL=TRUE)))); End; Run(ViewportRename); Hurrah! Edited September 23, 2023 by Tom W. 3 Quote Link to comment
michaelk Posted September 23, 2023 Share Posted September 23, 2023 Nice! Now you can write scripts to do anything you want! Quote Link to comment
Pat Stanford Posted September 23, 2023 Share Posted September 23, 2023 13 hours ago, Tom W. said: Again out of interest, is there a programming reason you know of to explain why VW hasn't added the functionality to allow VPs to be created with the naming of our choice automatically from the outset? There is no programming reason they could not do it since we have written many version of this script. There is a customer service reason. Almost everyone wants to do it THEIR way. And that means that you need to have a huge number of options (what is included, what special characters to use, what order to put everything in, etc.) so if VW was to do the script it would not be one of our simple 20 line scripts to accomplish a basic function, it would rather be more like a 2000 (or more) line script with lots of options and error checking, that would still probably only satisfy 70% of the users as either it will be too complicated for most to see as worthwhile, or will not handle their specific desired configuration. Think of something like the Data Tag editor. It will need to be something like that to be moderately useful to a large swath of users. 2 Quote Link to comment
Tom W. Posted September 23, 2023 Share Posted September 23, 2023 5 minutes ago, Pat Stanford said: There is a customer service reason. Almost everyone wants to do it THEIR way. And that means that you need to have a huge number of options (what is included, what special characters to use, what order to put everything in, etc.) so if VW was to do the script it would not be one of our simple 20 line scripts to accomplish a basic function, it would rather be more like a 2000 (or more) line script with lots of options and error checking, that would still probably only satisfy 70% of the users as either it will be too complicated for most to see as worthwhile, or will not handle their specific desired configuration. Thanks I thought it could just be like custom naming for file export where you can select fields from a list (sheet layer, drawing number, drawing title - what else?) in the order you want + add your own punctuation: Just need a few more options other than just 'drawing number/sheet number'. If someone wants something more complicated they'd still have the option of typing it in manually. 2 Quote Link to comment
Pat Stanford Posted September 23, 2023 Share Posted September 23, 2023 I agree. How high should that be on the priority list or 10MM things that need to be improved? 😉 Quote Link to comment
Christiaan Posted September 25, 2023 Share Posted September 25, 2023 Thanks Michael. Tom, this did the trick for me. You could remove the spaces from ' - ' Procedure ViewportRename; {Badly Scripted by Michael Klaers. Updated Aug 2, 2015} {This script will take all selected viewports and change the name of those viewports to be (Sheet Layer) (Drawing Number) (Drawing Name) This version tries to force the name to appear immeidately in the name field, data tab, OIP when only one VP is selected. Prior to this version the new name appeared immediately in the Nav Palette, but not in the name field.} Var VPDwgTitle,VPName,BText,VPNum : String; h,hh: Handle; ViewportLayer: Handle; ViewportLayerString: String; Procedure RenameVP(h : HANDLE); Begin {*********** BEGIN Procedure ***********} ViewportLayer:= GetLayer(h); ViewportLayerString:= GetLName(ViewportLayer); VPDwgTitle := GetObjectVariableString(h, 1032); VPNum := GetObjectVariableString(h, 1033); ResetObject(h); SetName(h, Date(2,2)); SetName(h, CONCAT(ViewportLayerString, ' - ',VPNum, ' - ',VPDwgTitle)); SetDSelect(h); {These two commands are just here to force the new name to appear in the } SetSelect(h); {name field immediately. They can be deleted w/o consequence} End; {*********** END Procedure ***********} Begin {*********** Main Program ***********} ForEachObject(RenameVP,(((T=VIEWPORT) & (SEL=TRUE)))); End; Run(ViewportRename); Quote Link to comment
Tom W. Posted September 25, 2023 Share Posted September 25, 2023 @michaelk I also gotta say that I'm using your worksheet scripts + loving them! I've had them for a while + to my shame always forget to drag them out + use them but not today! They're great! Love the Cell Border dialogs. Great work thank you. Quote Link to comment
michaelk Posted September 25, 2023 Share Posted September 25, 2023 @Tom W. Glad you find them useful! I also sometimes forget to include them in a file and/or drag them out. Or the drawing has old or alternate versions of the scripts. I finally made them into menu commands and gave them keyboard shortcuts. Now those scripts are just part of the workspace. Even better. 3 Quote Link to comment
Tom W. Posted September 25, 2023 Share Posted September 25, 2023 Three keys is the absolute maximum I can handle for keyboard shortcuts (🙂) but a dedicated menu is a very good idea! I only realised recently you could do that (duh). Do you rebuild your workspace from scratch each year though as I've been scared into doing? I've got about 200 screenshots to remind me what to do... Quote Link to comment
michaelk Posted September 25, 2023 Share Posted September 25, 2023 Yes I rebuild from scratch. If you don't it's easy to miss new tools and menus. If you go to Tools > Workspaces… there is an export button to create a text file of all the menus and tools in your workspace. It's a great way to make sure you don't forget something. Quote Link to comment
michaelk Posted September 25, 2023 Share Posted September 25, 2023 14 minutes ago, Tom W. said: Three keys is the absolute maximum I can handle for keyboard shortcuts (🙂) but a dedicated menu is a very good idea! I only realised recently you could do that (duh). Do you rebuild your workspace from scratch each year though as I've been scared into doing? I've got about 200 screenshots to remind me what to do... There's a secret keyboard combination for VW Mac users. (Shout out to @Mark Aceto). There is no option in the workspace editor for Shift+Option+key. Probably to ensure Windows compatibility. But you can use the Mac OS System Settings to bind those keyboard shortcuts to menu commands. Brings you back down to 3 keys! 1 Quote Link to comment
Tom W. Posted September 25, 2023 Share Posted September 25, 2023 21 minutes ago, michaelk said: Yes I rebuild from scratch. If you don't it's easy to miss new tools and menus. If you go to Tools > Workspaces… there is an export button to create a text file of all the menus and tools in your workspace. It's a great way to make sure you don't forget something. I've done that in the past but it just looked like gobbledegook to me I'll need to look closer...! Quote Link to comment
Mark Aceto Posted September 25, 2023 Share Posted September 25, 2023 19 minutes ago, michaelk said: There's a secret keyboard combination for VW Mac users. (Shout out to @Mark Aceto). There is no option in the workspace editor for Shift+Option+key. Probably to ensure Windows compatibility. But you can use the Mac OS System Settings to bind those keyboard shortcuts to menu commands. Brings you back down to 3 keys! 2's the key number here. Think about it. 2-Pac. 2 Fast 2 Furious. 2, man, that's the number. 2 chipmunks twirlin' on a branch, eatin' lots of sunflowers on my uncle's ranch. You know that old children's tale from the sea. It's like you're dreamin' about Gorgonzola cheese when it's clearly Brie time, baby. Step into my office. Anyway, the shortcuts also magically appear throughout the VW UI (menus, etc). Nevertheless, this is gonna spectacularly backfire on me when I get a PC... 1 Quote Link to comment
Cory W. Posted September 26, 2023 Author Share Posted September 26, 2023 This has thread has been hugely informative... I hope for those who commented and spectated as well. Thanks all for the input. Quote Link to comment
David S Posted September 27, 2023 Share Posted September 27, 2023 I've scanned this and it is touched upon but not explicitly I think. I was taught this by @Helen Law at VWUK and use it extensively now. Naming viewports allows you to link section viewports to design layers and viewports via section lines which appear automatically. Better still if you move the section line/s cut in the design layer they alter position automatically. More work up front but saves a lot of time in the long run. This can be activated by selecting your Section viewport(s), Going to the OI Pallette and clicking on section line instances (at bottom) within which you can nominate where you want the section lines to appear in both design layers and viewports. Cool! Quote Link to comment
Cristiano Alves Posted September 27 Share Posted September 27 On 9/21/2023 at 5:26 PM, michaelk said: There are several old versions of those scripts floating around. These are the most recent versions of those two scripts turned into menu commands: RenameVPs.vsm 5.35 kB · 15 downloads Renumber Sheet Layers.vsm 9.9 kB · 15 downloads hello @michaelk I am trying to instal these VSM files, but this extension doesn't appear on the Add files on Plugins Manager: Can you help me? Search about instal VMS files doesn't have much results. Quote Link to comment
michaelk Posted September 27 Share Posted September 27 You don't need to use the plug-in manager. Just manually put the files in the correct folder. In Vectorworks go to Preferences > User Folders. On the top right of the window will be a button that says Reveal in Finder for Macs and Reveal in Explorer for Windows. Click that button and it will open up your user folder. In that folder will be a Plug-Ins folder. Put the .vsm or .vso in that folder. Restart Vectorworks. Tools > Workspaces > Edit Current Workspace [OR] > Workspaces if you want to create a new workspace Now you should be able to find the menu commands in the left column and move them to your workspace in the right column. Quote Link to comment
Cristiano Alves Posted September 27 Share Posted September 27 24 minutes ago, michaelk said: You don't need to use the plug-in manager. Just manually put the files in the correct folder. In Vectorworks go to Preferences > User Folders. On the top right of the window will be a button that says Reveal in Finder for Macs and Reveal in Explorer for Windows. Click that button and it will open up your user folder. In that folder will be a Plug-Ins folder. Put the .vsm or .vso in that folder. Restart Vectorworks. Tools > Workspaces > Edit Current Workspace [OR] > Workspaces if you want to create a new workspace Now you should be able to find the menu commands in the left column and move them to your workspace in the right column. Thank you @michaelk Reset Vectorworks doesn't work. But I reboot the computer helps. Everything was ok now. One question: I understand the plugin rename with: [Sheet Number] [Drawing Number] [Drawing Title] How I can change the plugin to rename with: [Sheet Title] [Drawing Number] [Drawing Title] Is it possible? Quote Link to comment
michaelk Posted September 27 Share Posted September 27 This should do it. This file has one script. Open that script, select the entire contents of the script and copy. Got to Tools > Plug Ins > Plug In Manager select the rename viewports menu command in the list At the bottom click Edit Script. Delete everything and paste the script from this file. That should use the sheet layer title rather than the sheet layer name (which is usually a number 🙂 ). Rename Viewport Sheet Title.vwx 1 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.