Tom M. Posted April 24, 2023 Share Posted April 24, 2023 (edited) Hi there, Unfortunately, I have little to no experience with Vectorscript. So far I have created scripts via Marionette or menu commands. I often want to select Light Instruments by its "Fixture Name". Therefore I used Vectorscripts to select them by their individual name. Script looks like this: DSelectAll; SelectObj(INSYMBOL & INVIEWPORT & ((PON='Lighting Device') & ('Lighting Device'.'Inst Type'='ALEDA B-EYE K20'))); I have all these scripts in the Scriptpallette: 'Sel Scheinwerfer' The annoying thing is that so far I have to modify each script individually as soon as I add new light instruments to the drawing which I have not used before. It would be great if its possible to use a script that creates the individual scripts for the light instruments currently imported in the drawing. Is this possible? Maybe someone can point me in the right direction. Thanks for your help in advance Tom Edited April 24, 2023 by Tom M. updated signature Quote Link to comment
Jesse Cogswell Posted April 24, 2023 Share Posted April 24, 2023 @Tom M. Unfortunately, there's not really a way for a script to write scripts directly. You could write a script that could create text files or even .vsm menu commands, but that would still involve either creating the new scripts and copying and pasting from the text files, or restarting Vectorworks and adding the new menu commands to your workspace. If you went the route of the menu commands, you would also end up with a boat-load of commands depending on how many fixture types you work with. Instead, I propose this solution: the script below will search the drawing for all Lighting Device objects and will build an array of the Inst Type fields that it finds. Then, you can select the type or types that you want to select. It's an extra click, but it's a more flexible script from drawing to drawing. PROCEDURE SelectFixtures; {* Builds an array of Lighting Device types and allows user to select all of each type in drawing Developed by: Jesse Cogswell Date: 4/24/2023 Revisions: *} CONST kLightDevice = 'Lighting Device'; kInstType = 'Inst Type'; VAR lightTypes:DYNARRAY[] OF STRING; numTypes:INTEGER; dialog,layoutDialog:LONGINT; PROCEDURE AddToArray(h:HANDLE); {Adds lighting device to array} LABEL 99; {Escape} VAR testStr:STRING; i:INTEGER; BEGIN testStr:=GetRField(h,kLightDevice,kInstType); FOR i:=1 TO numTypes DO BEGIN IF(lightTypes[i] = testStr) THEN GOTO 99; END; numTypes:=numTypes+1; ALLOCATE lightTypes[1..numTypes]; lightTypes[numTypes]:=testStr; 99: {Escape} END; FUNCTION DrawDialog(DName:STRING) : LONGINT; {Creates dialog box and returns dialog ID} CONST kWidth = 50; kHeight = 50; VAR dia:LONGINT; BEGIN dia:=CreateLayout(DName,FALSE,'OK','Cancel'); CreateListBoxN(dia,11,kWidth,kHeight,TRUE); CreateGroupBox(dia,101,'Instrument Types',TRUE); SetFirstGroupItem(dia,101,11); SetFirstLayoutItem(dia,101); DrawDialog:=dia; END; PROCEDURE DialogHandler(VAR item,data:LONGINT); {Handles dialog box} VAR i,index:INTEGER; selectInst:STRING; BEGIN CASE item OF SetupDialogC: BEGIN FOR i:=1 TO numTypes DO AddChoice(dialog,11,lightTypes[i],i-1); END; 1: {OK} BEGIN FOR i:=1 TO numTypes DO BEGIN GetSelectedChoiceInfo(dialog,11,i-1,index,selectInst); IF(index <> -1) THEN ForEachObject(SetSelect,((R IN [kLightDevice]) & (kLightDevice.kInstType = selectInst))); END; END; 2: {Cancel} BEGIN END; END; END; BEGIN numTypes:=0; DSelectObj(ALL); ForEachObject(AddToArray,(R IN [kLightDevice])); IF(numTypes>0) THEN BEGIN SortArray(lightTypes,numTypes,0); dialog:=DrawDialog('Select Lighting Fixtures'); layoutDialog:=RunLayoutDialog(dialog,DialogHandler); END ELSE AlrtDialog('No Lighting Fixtures found in drawing'); END; Run(SelectFixtures); 1 Quote Link to comment
Tom M. Posted April 24, 2023 Author Share Posted April 24, 2023 Hi Jesse, wow thank you very much for sharing this script. It's close to what I was looking for. Great timesaver for me. Thank you! 1 Quote Link to comment
Tom M. Posted April 24, 2023 Author Share Posted April 24, 2023 So happy with your help. The script brings me directly to another idea. Do you think it is also possible to create a script that selects the remaining fixtures of the same type used in the drawing based on an activated fixture? So if I have a Fixture selected I run a Shortcut to select the rest of the same Fixtures? Bonus. Possibly even for similar plugin objects, like speakers etc.? Tia Tom 1 Quote Link to comment
Pat Stanford Posted April 24, 2023 Share Posted April 24, 2023 I think the Select Similar Tool will already do this. 1 Quote Link to comment
Jesse Cogswell Posted April 24, 2023 Share Posted April 24, 2023 @Pat Stanford is exactly correct in terms of selecting similar plug-in types and is something I use all the time. It looks like a "Magic Wand" and can be configured to work in all kinds of ways. What you would be looking for is something like this: You can save "presets" for what you want it to do, changeable in the Mode Bar when you activate the Select Similar tool. I have one for Object Type, Symbol Name, and Class. What it won't do is select similar based on a single parameter such as fixture type. But that's easy enough to script: PROCEDURE SelectSimilarFixture; {* Selects the same fixture types as selected Lighting Device objects on the active Layer Developed by: Jesse Cogswell Date: 4/23/2023 Revisions: *} CONST kLightDevice = 'Lighting Device'; kInstType = 'Inst Type'; VAR currentLayer:STRING; check:BOOLEAN; PROCEDURE SelectSimilar(h:HANDLE); VAR testStr:STRING; BEGIN check:=TRUE; testStr:=GetRField(h,kLightDevice,kInstType); ForEachObject(SetSelect,((R IN [kLightDevice]) & (kLightDevice.kInstType = testStr))); END; BEGIN check:=FALSE; currentLayer:=GetLName(ActLayer); ForEachObject(SelectSimilar,((SEL) & (L=currentLayer) & (R IN [kLightDevice]))); IF NOT check THEN AlrtDialog('No Lighting Devices currently selected on active Layer'); END; Run(SelectSimilarFixture); 2 Quote Link to comment
Tom M. Posted April 24, 2023 Author Share Posted April 24, 2023 Wow amazing! I really appreciate your help Jesse and Pat! I knew about the Select Similiar tool, but didn't think about saving defaults. Thank you all for the push in the right direction. 1 Quote Link to comment
C. Andrew Dunning Posted April 24, 2023 Share Posted April 24, 2023 7 hours ago, Tom M. said: I often want to select Light Instruments by its "Fixture Name". You might find this suite of commands & tools to be helpful: https://autoplotvw.com/. Included are several selection methods. MORE than worth the $... 3 Quote Link to comment
Wesley Burrows Posted April 25, 2023 Share Posted April 25, 2023 I've used this plugin for years, it's a select similar wand tool specifically for lighting instruments. You can select by name, type, position, etc. https://benghiatlighting.com/software/product/savvy-select-similar-instrument-3/ 4 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.