[Kr...] Posted August 17, 2022 Share Posted August 17, 2022 Good Morning, I am trying to create a script that allows the user to input data for the project keywords. I have wrote an export script that runs a variety of other scripts and outputs all the required data however the projects contain approx. 15 keywords that need to be updated per measure. Is there a way to create a dialogue box at the start of my export script that runs the user through the keywords and allows them to input the required data which then updates the keywords within the project. I appreciate the keywords could be updated via the project keywords function however I want to try and contain it all within one script as a "one stop export" solution. Any help is appreciated as I'm struggling to get my head around the dialogue inputs within scripting. Kind Regards Kris Link to comment Share on other sites More sharing options...
[Kr...] Posted August 17, 2022 Author Share Posted August 17, 2022 This is the code I currently have. As you can see I've set up a basic dialog box (for now) that allows the user to input a name for inspector 1 & inspector 2. What I need is the input of this dialog box (labelled up "Insp_1") to replace the inspector name located in the project keywords. Hopefully this gives a little more information as to what I'm trying to achieve. import gom DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \ ' <title>Dialog Title</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position></position>' \ ' <embedding></embedding>' \ ' <sizemode></sizemode>' \ ' <size width="295" height="196"/>' \ ' <content rows="3" columns="2">' \ ' <widget row="0" type="label" column="0" rowspan="1" columnspan="1">' \ ' <name>Insp_1_Lab</name>' \ ' <tooltip></tooltip>' \ ' <text>Inspector #1</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget row="0" type="input::string" column="1" rowspan="1" columnspan="1">' \ ' <name>Insp_1</name>' \ ' <tooltip></tooltip>' \ ' <value>Name</value>' \ ' <read_only>false</read_only>' \ ' <password>false</password>' \ ' </widget>' \ ' <widget row="1" type="label" column="0" rowspan="1" columnspan="1">' \ ' <name>Insp_2_Lab</name>' \ ' <tooltip></tooltip>' \ ' <text>Inspector #2</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget row="1" type="input::string" column="1" rowspan="1" columnspan="1">' \ ' <name>Insp_2</name>' \ ' <tooltip></tooltip>' \ ' <value>Name</value>' \ ' <read_only>false</read_only>' \ ' <password>false</password>' \ ' </widget>' \ ' <widget row="2" type="label" column="0" rowspan="1" columnspan="1">' \ ' <name>Pre_Dat_Lab</name>' \ ' <tooltip></tooltip>' \ ' <text>Press Date</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget row="2" type="input::date" column="1" rowspan="1" columnspan="1">' \ ' <name>Pre_Date</name>' \ ' <tooltip></tooltip>' \ ' <use_current_date>true</use_current_date>' \ ' <show_today_button>true</show_today_button>' \ ' <default_date>' \ ' <year>2022</year>' \ ' <month>8</month>' \ ' <day>17</day>' \ ' </default_date>' \ ' </widget>' \ ' </content>' \ '</dialog>') ## Event handler function called if anything happens inside of the dialog. def dialog_event_handler (widget): pass DIALOG.handler = dialog_event_handler RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG) gom.script.sys.set_project_keywords ( keywords={'Inspector': 'Kris'}, keywords_description={'Inspector': 'Inspector'}) Link to comment Share on other sites More sharing options...
[Ja...] Posted August 18, 2022 Share Posted August 18, 2022 Hey Kristian , hope you are well. Long time no speak. Not easy for me to post code on here anymore , but the output of a dialogue gets accessed by RESULT.object name, so in your case either RESULT.Insp_1 or RESULT.Insp_2 Id store in varable say Inspector1 = RESULT.Insp_1 You then reference that in the keyword setting . Exchange 'Kris' for the variable , e.g Inspector1. . Take care that inspector1 variable is not inside speech marks , text will be black if called as a variable. Hope this helps Link to comment Share on other sites More sharing options...
[Kr...] Posted August 18, 2022 Author Share Posted August 18, 2022 Hey James, It has been a long time indeed. I am very well thank you, I hope you are too. I see it's difficult to leave the old stuff behind. I've tweaked the script to include what you have mentioned, works a treat. I was almost there I was just unsure how to reference the dialog inputs as a variable but there is no stopping me now. As always thank you for your assistance. Cheers, Kris. Link to comment Share on other sites More sharing options...
[Ja...] Posted August 18, 2022 Share Posted August 18, 2022 Super , glad it has worked. I still use the software daily so if I can help others then its all good ! Link to comment Share on other sites More sharing options...
[Kr...] Posted August 19, 2022 Author Share Posted August 19, 2022 Well as always I appreciate the coding help. I've got another issue which might be a bit more complicated if you could offer some guidance. Is there a way to set up the code/dialog box so that the already set keywords are shown as default? For example if the keyword 'inspector 1' already says 'Kris'. The dialog box will represent or show this meaning the user doesn't have to input a new keyword? Link to comment Share on other sites More sharing options...
[Ma...] Posted December 18, 2023 Share Posted December 18, 2023 Hi, I am not quite sure if this is what you were looking for, but in SW2023, gom.api.settings allows that entries made in a dialog will be retained. Best regards, Matthias Prinke 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