Jiajing Posted April 12, 2022 Share Posted April 12, 2022 On 1/17/2008 at 5:28 PM, Pat Stanford said: Jonathan is correct that it can be done, but how to do it depends on what you are trying to do. So, what are you trying to do? Is it your symbol or just some generic symbol? Do you want to just go into the symbol edit mode, or do you want to make the changes and have them applied to all of the instances in the drawing? Tell us more and we can probably help you. Pat HI Pat, I am trying to go into the lighitng symbol, change geometry attributes and apply that changes to all instance in the drawing. any leads are appreciated. Quote Link to comment
Pat Stanford Posted April 12, 2022 Share Posted April 12, 2022 I split this into a different thread since you tagged onto a 14 year old conversation. 😉 As far as I know symbols of lights are usually pretty complicated objects and specific parts need to have specific records attached to make them work properly. I don't know all of the internal details of what needs to be don't in light symbols. Since you want all instances in the drawing changed you only need to edit the symbol definition. How much programming experience do you have? It is relatively easy to get a handle to a symbol definition from a selection on the drawing. Then you can get a handle to the first object in the symbol definition and "walk" through the list to find the objects you want to change. But you will pretty much have to test every object in the symbol to see if it is the one you are interested. Once you find it, you can modify it however you want. But why do you want to do this by script? Unless you have a very large number of symbols that need to be changed in a very similar way, a script may not work well as each symbol could be made differently and you could need to modify the script for every symbol. Is this something you want to be able to change back and forth between different sets of attributes? If so, you might be better off editing the symbols to have the attributes set to By Class and then just edit the class attribute settings as needed. More definition of what you are trying to do will help with the solution. 2 Quote Link to comment
Jesse Cogswell Posted April 14, 2022 Share Posted April 14, 2022 @Jiajing I believe what you are looking for is FInGroup to traverse through a symbol definition. I have written out a simple script below that will traverse the symbol definition of a selected Lighting Device object and set the pen attributes of all symbol geometry to be By Class. PROCEDURE UpdateLightingDeviceSymbol; { Traverses symbol geometry for selected Lighting Device Objects Developed by: Jesse Cogswell VW Version: 2019 Date: 4/13/2022 } CONST kLightingRecord = 'Lighting Device'; kSymbolField = 'Symbol Name'; PROCEDURE UpdateSymbol(h:HANDLE); {Pulls symbol for given lighting device object and traverses geometry} VAR lightSymName:STRING; symDefHd,h2:HANDLE; BEGIN lightSymName:=GetRField(h,kLightingRecord,kSymbolField); symDefHd:=GetObject(lightSymName); h2:=FInGroup(symDefHd); WHILE(h2<>NIL) DO BEGIN {FILL IN WHAT YOU WANT TO DO TO EACH OBJECT HERE} SetPenColorByClass(h2); h2:=NextObj(h2); END; ForEachObject(ResetObject,((R IN [kLightingRecord]) & (kLightingRecord.kSymbolField=lightSymName))); END; BEGIN ForEachObject(UpdateSymbol,((R IN [kLightingRecord]) & (SEL=TRUE))); END; Run(UpdateLightingDeviceSymbol); The works by following these steps: Use ForEachObject with the criteria to find Lighting Device objects that are also selected (may not be a bad idea to throw an additional criteria for selected objects on the active layer to prevent the script from being run on selected objects not on the active layer when not in Show/Snap/Modify) to start a PROCEDURE that I called UpdateSymbol. Use GetRField to pull the "Symbol Name" record field from given lighting device. Use GetObject with the symbol name to get a handle to the symbol definition used by the Lighting Device. Use FInGroup with the handle to the symbol definition to get a handle to the first object inside the symbol definition. Use a WHILE loop with the criteria set to <>NIL, this will ensure that the script will go through each object of the symbol definition and will terminate when the handle equals NIL (no object). This loop is where you will set your code to alter the geometry attributes. In my example, I am using SetPenColorByClass to ensure that the object has its pen color attribute to be set by class (as I think you mentioned in the other thread). Use NextObj to cycle to the next object inside the symbol definition. THIS IS SUPER IMPORTANT TO HAVE, OTHERWISE THE WHILE LOOP NEVER COMPLETES AND VECTORWORKS WILL CRASH! Once the loop terminates, you will need to make sure that the given Lighting Device object resets so that it will reflect the changes made to the symbol definition. Normally, you would do this with ResetObject(h); However, in this instance, you want to make sure that all other Lighting Device objects that use this definition are also updated, so instead you would do this with ForEachObject with the criteria set to look for Lighting Device objects whose "Symbol Name" field match the symbol definition. Is this what you are looking to do? As @Pat Stanford mentions above, this can be a dangerous operation, as you might not always want EVERY object inside a symbol definition to have their attributes set the same way. 3 Quote Link to comment
Jiajing Posted April 17, 2022 Author Share Posted April 17, 2022 (edited) @PatStanfordI am defenitely learning coding. I would love to traverse throught all objects inside lighting symbol and change their attributes to start, the reason I wasn't able to do that by SETCLASS simply becasue customized symbol libraries may not well maintained and objects could be assigned to mutiple classes, which is not easy to keep track on. @Jesse Cogswell Really appreciate on pointing me to the right direction. Good to know VWX is using FInGroup to reach inside lighting symbol, that is a huge help. One thing I do notice is that following criteria doesn't necessary work on VW2022 SP3 for some reason. import vs; vs.SelectObj("INOBJECT & (S='Light Instr ETC Source 4 LED Studio HD 10deg')"); The above script should select 10deg leko in the document, but it doesn't. I am working on find alternative criteria to RESETOBJECT. Edited April 17, 2022 by Jiajing Quote Link to comment
Pat Stanford Posted April 17, 2022 Share Posted April 17, 2022 I am far from a Spotlight expert, but I don't think a Lighting Device actually contains the symbol of the light object. I think it just uses the symbol to hold geometry that it then imports. So you will probably not be able to find that symbol in the drawing if you are using it in lighting devices. If you want to learn about scripting, just keep posting your questions. There are a number of us here including @Jesse Cogswell, @michaelk, @MullinRJ, @Sam Jones, and many other who I am blanking on right now who are happy to help get you over the hurdles. Quote Link to comment
Jiajing Posted April 17, 2022 Author Share Posted April 17, 2022 @PatStanford import vs; vs.SelectObj("INOBJECT & (S='Light Instr ETC Source 4 LED Studio HD 10deg')"); It does not work on script, but when I create that criteria using CUSTOME SELECTION, in that dialogue it does show number of symbols match that criteria. However, it just does not work by simply running the pure script. Circle back to @Jesse Cogswell original post, I ended up using ('Lighting Device'.'Symbol Name'={LightSymbolName}) # fstring here That works great. Always learning. Thank you Quote Link to comment
Tim Harland Posted November 21, 2024 Share Posted November 21, 2024 Hi @Pat Stanford istit possible to create a Vectorscript that simply opens the 2D editing pane of each symbol on a particular design layer or a selection of symbols and then closes it? We have an issues with the visibility of referenced symbols that seems to only be solved when we open the symbol and close it again. We have several hundred symbols though so it would be great to automate this process as a workaround to the bug in Vectorworks. Quote Link to comment
michaelk Posted November 22, 2024 Share Posted November 22, 2024 (edited) I've been thinking about this for a while. (because I'd like to do something similar myself) I can make a script work for one symbol, or if multiple are selected, it works for the last one. Don't test this on an actual working file. I've only tested it with a few trivial symbols. I'm expecting the hive mind to jump in and come up with an actual fix 🙂. PROCEDURE Test; VAR FrstObj :HANDLE; s : STRING; PROCEDURE DoIt(h:HANDLE); BEGIN EditObjectSpecial(h,4); FrstObj := FInSymDef(h); HMove(FrstObj,0,0); {probably doesn't help} ReDrawAll; {probably doesn't help} END; BEGIN s := Date(0,2); VSave(s); ForEachObject(DoIt,((VSEL=TRUE))); VRestore(s); VDelete(s); END; RUN(Test); Edited November 22, 2024 by michaelk HMove should be on FrstObj. Not that it matters. Neither one works. 1 Quote Link to comment
MullinRJ Posted November 22, 2024 Share Posted November 22, 2024 Try this one on for size. It steps through the symbol library and does not require any symbols to be placed in the drawing. Visit Symbols.vs HTH, Raymond 2 Quote Link to comment
michaelk Posted November 22, 2024 Share Posted November 22, 2024 Nice, Raymond. It doesn't force a symbol definition update. Reading between the lines I think that's what @Tim Harland was looking for. I have a script I often use that modifies an existing symbol, but it doesn't refresh the symbol definition. So it's necessary to open and close the edit window. I think Tim has a similar problem with referenced symbols. This gives me hope that it's possible :-). 1 Quote Link to comment
Pat Stanford Posted November 22, 2024 Share Posted November 22, 2024 I wonder is you could just do a ResetObj(SymDefHandle) followed by a RedrawAll to force the same thing without having to open the edit window? Quote Link to comment
michaelk Posted November 22, 2024 Share Posted November 22, 2024 I'll give that a shot. Meanwhile I don't think we've answered @Tim Harland's question. Tim could are you trying to update symbols in the file providing the referenced symbols? Or are you trying to update symbols while in the active file? If you could provide sample files that would help. Quote Link to comment
MullinRJ Posted November 23, 2024 Share Posted November 23, 2024 9 hours ago, michaelk said: It doesn't force a symbol definition update. Reading between the lines I think that's what @Tim Harland was looking for. Well, I provided the script asked for. You say it not does not update the symbol, but it used to. However, due to speed issues I switched to ResetObject() quite a while back. I can confirm that ResetObject(H) in the FEOIL function will reset symbol definitions in the drawing, but I don't use referenced symbols so I didn't want to guess how they would be affected. Nor did I have the time to try to recreate his particular scenario. I can also confirm that RedrawAll is not needed to complete a symbol update. Raymond Quote Link to comment
Tim Harland Posted November 24, 2024 Share Posted November 24, 2024 On 11/22/2024 at 8:08 PM, michaelk said: Nice, Raymond. It doesn't force a symbol definition update. Reading between the lines I think that's what @Tim Harland was looking for. I have a script I often use that modifies an existing symbol, but it doesn't refresh the symbol definition. So it's necessary to open and close the edit window. I think Tim has a similar problem with referenced symbols. This gives me hope that it's possible :-). Yes exactly, the old "give it a thump" trick that Vectorworks somethimes requires! Quote Link to comment
Tim Harland Posted November 24, 2024 Share Posted November 24, 2024 On 11/22/2024 at 8:43 PM, michaelk said: I'll give that a shot. Meanwhile I don't think we've answered @Tim Harland's question. Tim could are you trying to update symbols in the file providing the referenced symbols? Or are you trying to update symbols while in the active file? If you could provide sample files that would help. See attached for a test file - we have a couple of different issues, both of which are solved by opening the symbol in the file providing the referenced symbols and closing it again. One thing to note - our symbol is a bit complicated as it is a symbol inside another symbol (so that we can push updates to record fields out to references files), I am pretty sure that is where the issue lies. In the attached instance the content in the library file which has been updated via a worksheet is not updating in the file in which it is referenced. We also have another example where the symbol inside the symbol is simply not visible at all in the referenced file. In both cases opening the symbol in the library file and closing it again solves the issue. Note Library.vwx Test Datei.vwx Quote Link to comment
Tim Harland Posted November 24, 2024 Share Posted November 24, 2024 3 minutes ago, Tim Harland said: See attached for a test file - we have a couple of different issues, both of which are solved by opening the symbol in the file providing the referenced symbols and closing it again. One thing to note - our symbol is a bit complicated as it is a symbol inside another symbol (so that we can push updates to record fields out to references files), I am pretty sure that is where the issue lies. In the attached instance the content in the library file which has been updated via a worksheet is not updating in the file in which it is referenced. We also have another example where the symbol inside the symbol is simply not visible at all in the referenced file. In both cases opening the symbol in the library file and closing it again solves the issue. Note Library.vwx 83.78 kB · 0 downloads Test Datei.vwx 81.17 kB · 0 downloads @MullinRJ your Script worked for this particular issue, thanks! I'll test it on our other case as soon as it pops up again. Quote Link to comment
Tim Harland Posted November 24, 2024 Share Posted November 24, 2024 41 minutes ago, Tim Harland said: @MullinRJ your Script worked for this particular issue, thanks! I'll test it on our other case as soon as it pops up again. @MullinRJ Update number 2 - it also worked on the other issue we had - thanks a million - that saves opening & closing ca. 3000 Symbols by hand!. 1 Quote Link to comment
MullinRJ Posted November 24, 2024 Share Posted November 24, 2024 Hello @Tim Harland, You are very welcome. Glad I could help. I was there nearly 15 years ago when I first tried this approach. Your question brought back memories. Because it sometimes runs quite slowly, I also tried ResetObject() in place of the Open/Close Edit Symbol calls, which worked for me and sped things up a bit. You might try it, too. Maybe try it multiple times because some symbols are nested, though I'm not sure if that will do anything. It may be worth a try. All the best, Raymond 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.