Nico_be Posted June 27, 2023 Share Posted June 27, 2023 Hello, I'm looking for a way to change the parameters of a plant style automatically on dozens of plants at a time, via a script for example: I'd like the plant label parameters to change from "by style" to "by object". Manually, I have to edit each plant and click 14 times... Does anyone have an idea for changing this automatically, in batch? Thanks! 1 Quote Link to comment
Vectorworks, Inc Employee Popular Post Katarina Ollikainen Posted June 27, 2023 Vectorworks, Inc Employee Popular Post Share Posted June 27, 2023 Hi, this is included in 2023 and I've made a quick video on how to use it. MassEditPlantStyle(''); Hope it helps. Change plant style settings.mp4 11 5 Quote Link to comment
Nico_be Posted June 28, 2023 Author Share Posted June 28, 2023 This is exactly the script I was hoping for! Great, thanks @Katarina Ollikainen ! 1 Quote Link to comment
Amanda McDermott Posted July 6, 2023 Share Posted July 6, 2023 On 6/27/2023 at 3:10 PM, Katarina Ollikainen said: Hi, this is included in 2023 and I've made a quick video on how to use it. MassEditPlantStyle(''); Hope it helps. Change plant style settings.mp4 Thank you Katarina, this has saved me lots of time! 1 Quote Link to comment
Nico_be Posted July 7, 2023 Author Share Posted July 7, 2023 Hello @Katarina Ollikainen Would it be possible to insert this script into a more complex script that would allow multiple parameters to be changed at once, instead of rerunning it for each parameter? Or turn it into a marionette node? Quote Link to comment
Vectorworks, Inc Employee Popular Post Katarina Ollikainen Posted July 7, 2023 Vectorworks, Inc Employee Popular Post Share Posted July 7, 2023 @Nico_be, we're working on a different approach to manage plant styles - it will be a more streamlined approach, and you won't need to run a script, so it will be better suited for most users. I can't promise when this will be done, but we're actively working on it. 4 1 Quote Link to comment
Piotr Karczewski Posted December 7, 2023 Share Posted December 7, 2023 On 6/27/2023 at 4:10 PM, Katarina Ollikainen said: Hi, this is included in 2023 and I've made a quick video on how to use it. MassEditPlantStyle(''); Hope it helps. Change plant style settings.mp4 @Katarina Ollikainen this is incredibly amazing, love Your help! Quote Link to comment
Piotr Karczewski Posted December 8, 2023 Share Posted December 8, 2023 @Katarina Ollikainen do You have a recipe for (Plants) Textures mass edition? Thanks for Your help in advance. 1 Quote Link to comment
Ben Miura Posted September 10, 2024 Share Posted September 10, 2024 @Katarina OllikainenThanks so much for this. Just started using it in 2024 and it's returning the plant label as OK am I doing something wrong? Quote Link to comment
Vectorworks, Inc Employee Katarina Ollikainen Posted September 16, 2024 Vectorworks, Inc Employee Share Posted September 16, 2024 @Ben Miura, Can you please post a sample file with the result you get - I'm not sure where the OK shows up for you. Also, I would recommend using the data tag for the plant instead of the built-in tag, as you'll have more control over it. Quote Link to comment
Nico_be Posted Monday at 11:24 AM Author Share Posted Monday at 11:24 AM (edited) Hi, I was tired of having to run the MassEditPlantStyle script for each label field, so after some research, I created a small marionette node that allows you to change all the parameters of the plant labels in the file by setting them “by style” or “by instance.” The other node below allows you to configure each field “by style” or “by instance” separately, which affects all the plants in the file. It's in French, and if I have some time, I'll translate it into English. It'll be easier and faster that way! If you prefer a script: import vs # --- VARIABLES GLOBALES --- g_choix_tag = '16383' g_plant_folder = '' kID_TextInfo = 10 kID_CheckStyle = 11 kID_CheckInstance = 12 kID_FolderName = 13 kID_FolderMenu = 14 styles_modifies = [] # --- RÉCUPÉRATION DES DOSSIERS DE SYMBOLES --- def get_plant_folders(): folders = [] listID, numItems = vs.BuildResourceList(16, 0, '') for i in range(1, numItems + 1): objH = vs.GetResourceFromList(listID, i) if objH: parentH = vs.GetParent(objH) if parentH: typeN = vs.GetTypeN(parentH) name = vs.GetName(parentH) if typeN == 92 and name and name not in folders: folders.append(name) return sorted(folders) # --- DIALOG --- def CreateMyDialog(): dialog = vs.CreateLayout("Configuration des Tags de Plante", True, "Appliquer", "Annuler") vs.CreateStaticText(dialog, kID_TextInfo, "Les modifications seront appliquées aux plans placés sur le layer actif", 60) vs.CreateCheckBox(dialog, kID_CheckStyle, "Passer en mode : By STYLE") vs.CreateCheckBox(dialog, kID_CheckInstance, "Passer en mode : By INSTANCE") vs.CreateStaticText(dialog, kID_FolderName, "Dossier ressources plantes :", 40) vs.CreatePullDownMenu(dialog, kID_FolderMenu, 40) # ← ID séparé pour le menu vs.SetFirstLayoutItem(dialog, kID_TextInfo) vs.SetBelowItem(dialog, kID_TextInfo, kID_CheckStyle, 0, 0) vs.SetBelowItem(dialog, kID_CheckStyle, kID_CheckInstance, 0, 0) vs.SetBelowItem(dialog, kID_CheckInstance, kID_FolderName, 0, 4) vs.SetRightItem(dialog, kID_FolderName, kID_FolderMenu, 0, 0) return dialog def make_handler(dialog, folders): def DialogHandler(item, data): global g_choix_tag, g_plant_folder if item == -1 or item == 12255: # SetupDialogC — les deux valeurs selon la version vs.SetBooleanItem(dialog, kID_CheckInstance, True) g_choix_tag = '16383' for folderName in folders: vs.AddChoice(dialog, kID_FolderMenu, folderName, 0) if folders: vs.SelectChoice(dialog, kID_FolderMenu, 0, True) elif item == kID_CheckStyle: vs.SetBooleanItem(dialog, kID_CheckInstance, False) vs.SetBooleanItem(dialog, kID_CheckStyle, True) g_choix_tag = '0' elif item == kID_CheckInstance: vs.SetBooleanItem(dialog, kID_CheckStyle, False) vs.SetBooleanItem(dialog, kID_CheckInstance, True) g_choix_tag = '16383' elif item == 1: # Bouton Appliquer selectedIndex = vs.GetSelectedChoiceIndex(dialog, kID_FolderMenu, 0) if selectedIndex >= 0: g_plant_folder = folders[selectedIndex] return DialogHandler # --- LOGIQUE RESSOURCES --- def get_resources_in_folder(folderName, resourceType=16): objList = [] hFolder = vs.GetObject(folderName) if hFolder is None: return objList listResourcesID, numItems = vs.BuildResourceList(resourceType, 0, '') for cnt in range(1, numItems + 1): objH = vs.GetResourceFromList(listResourcesID, cnt) if objH is not None: parentH = vs.GetParent(objH) if parentH == hFolder: tempStr = vs.GetNameFromResourceList(listResourcesID, cnt) objList.append((tempStr, objH)) return objList # --- LOGIQUE STYLE --- def modifier_pio_in_style(hSymDef): hChild = vs.FInGroup(hSymDef) while hChild: if vs.GetTypeN(hChild) == 86: vs.SetRField(hChild, 'Plant', '__Tag_value_flags', g_choix_tag) vs.ResetObject(hChild) break hChild = vs.NextObj(hChild) vs.ResetObject(hSymDef) def modifier_styles_depuis_ressources(folderName): resources = get_resources_in_folder(folderName, resourceType=16) for styleName, hSymDef in resources: if styleName not in styles_modifies: modifier_pio_in_style(hSymDef) styles_modifies.append(styleName) # --- LOGIQUE INSTANCES --- def modifier_instance(h): if vs.GetTypeN(h) == 86: vs.SetRField(h, 'Plant', '__Tag_value_flags', g_choix_tag) vs.ResetObject(h) # --- EXECUTION --- dialog = CreateMyDialog() folders = get_plant_folders() if vs.RunLayoutDialog(dialog, make_handler(dialog, folders)) == 1: styles_modifies = [] if g_plant_folder: modifier_styles_depuis_ressources(g_plant_folder) vs.ForEachObject(modifier_instance, "(T=86)") vs.ReDrawAll() mode_str = "by STYLE" if g_choix_tag == '0' else "by INSTANCE" vs.AlrtDialog(f"Succès : Toutes les étiquettes de plantes sont maintenant en mode {mode_str}") Plants tags by Style or by Instance V1_1.vwx Edited Tuesday at 10:00 AM by Nico_be The style was not modified in the resources, but now everything works. 3 Quote Link to comment
Vectorworks, Inc Employee Katarina Ollikainen Posted Monday at 01:56 PM Vectorworks, Inc Employee Share Posted Monday at 01:56 PM @Nico_be, that is a nice script. I'm sure that went much faster than having to go through one setting at a time. If you don't have access to it, I would suggest opening the file with the plants you want to change and then start the Plant Style Manager. You can batch edit anything that is allowed with the identical setting there, and this includes the by style/by instance settings (You can't batch edit things like plant ID and style name, as they must be unique in the file). 1 Quote Link to comment
Nico_be Posted Monday at 02:07 PM Author Share Posted Monday at 02:07 PM 10 minutes ago, Katarina Ollikainen said: @Nico_be, that is a nice script. I'm sure that went much faster than having to go through one setting at a time. If you don't have access to it, I would suggest opening the file with the plants you want to change and then start the Plant Style Manager. You can batch edit anything that is allowed with the identical setting there, and this includes the by style/by instance settings (You can't batch edit things like plant ID and style name, as they must be unique in the file). @Katarina Ollikainen Yes, but I have to modify column by column (field by field), and during my last attempt, VW crashed. It was on a file with 2,000 plants. Here, with this script, it's much smoother and faster. 1 Quote Link to comment
Nico_be Posted Monday at 03:48 PM Author Share Posted Monday at 03:48 PM (edited) Unfortunately, I just realized that although the change is visible in the OIP, it is not reflected in the plant style; the settings remain unchanged when editing the plant... If anyone has any ideas, I'm interested!🤪 EDIT:See original message, everything is OK now. Edited Tuesday at 07:46 AM by Nico_be 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.