[Ma...] Posted Wednesday at 07:54 AM Share Posted Wednesday at 07:54 AM Hallo zusammen, ich nehme mal an, dass folgendes per Skript realisierbar ist. Es sollen keywords aus dem Namen des IST-Netzes in die keyword-Liste eingetragen werden. Also wenn der Name des Netzes immer folgendes Schema hat "Auftragsnummer_Kunde_Gießdatum_...", dass man daraus automatisch die keywords "Auftragsnummer", "Kunde", Gießdatum" usw. eingetragen bekommt. Das Ganze dann über alle Stufen des Projekts. Vielen Dank Link to comment Share on other sites More sharing options...
[Ma...] Posted Thursday at 09:50 AM Share Posted Thursday at 09:50 AM This can be done in script. Altering keywords is in AddOn examples - i think there is in examples a way to get mesh name, so this script can be within a few lines of code. I am still on beginning of programming on this, so i don't know how to make it automatically after mesh insertion - for now i would make it to run after button click. Also you can define some settings for this script in Inspect preferences, so you don't need to hardcode scheme. Link to comment Share on other sites More sharing options...
[Ma...] Posted Friday at 06:36 AM Author Share Posted Friday at 06:36 AM Dass das per Skript irgendwie geht, ist mir ja schon klar gewesen.. nur wie? Link to comment Share on other sites More sharing options...
[Ma...] Posted Friday at 07:58 AM Share Posted Friday at 07:58 AM I can try something, but you have to wait max to monday. If you want, you can send me PM or post here how you want to have it parsed and we can make something. Link to comment Share on other sites More sharing options...
[Ma...] Posted Friday at 09:02 AM Share Posted Friday at 09:02 AM (edited) Hi, To get the mesh name: print(f"{gom.app.project.parts['Training Object'].actual.name=}") # => Zeiss training object (extracted) 1.red Material 1 # Using the part index instead of the part name print(f"{gom.app.project.parts[0].actual.name}") # => Zeiss training object (extracted) 1.red Material 1 If the mesh element has element keywords: for keyword in gom.app.project.parts['Training Object'].actual.element_keywords: print(f"{keyword=}, value: {gom.app.project.parts['Training Object'].actual.get(keyword)}") # => keyword='user_Test', value: Zeiss training object To get the mesh names from stages: see Working with stages — App Development Documentation. To split a name like Auftragsnummer_Kunde_Gießdatum_... with underscore ('_') as separator: auftragsnummer, kunde, giessdatum = gom.app.project.parts[0].actual.name.split('_') Please refer to Project keywords handling — App Development Documentation for writing project keywords. Best regards, Matthias Edited Friday at 09:08 AM Link to comment Share on other sites More sharing options...
[Ma...] Posted Friday at 05:35 PM Share Posted Friday at 05:35 PM Here is safe working script if anyone needs # -*- coding: utf-8 -*- import gom # Getting name from mesh mesh_name = gom.app.project.parts[0].actual.name # Saving into variables - delimiter: "_" keyword_list = mesh_name.split('_') # Default values _order = '' _customer = '' _date = '' # Filling cycle for x in range( len(keyword_list) ): if x == 0: _order = keyword_list[x] elif x == 1: _customer = keyword_list[x] elif x == 2: _date = keyword_list[x] # Storing into project keywords gom.script.sys.set_project_keywords ( keywords={ 'order': _order, 'customer': _customer, 'date': _date }, keywords_description={ 'order': 'Order number', 'customer': 'Customer', 'date': 'Mold date' } ) # Doc ''' #Default values -> define own variable names used in scripts and their default value #Filling cycle -> continue to fill all needed keywords cycle runs from 0 as first element #Storing into keywords Example definition: keywords={'ORDER': _ORDER_}, keywords_description={'ORDER': 'DESCRIPTION TEXT'} <-- needed for creating new keyword if not existing 'ORDER' -> keyword name -> in report it's called by 'USER_ORDER' _ORDER_ -> your variable 'DESCRIPTION TEXT' -> Visible text on keyword form ''' Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in