How to write a script to create a custom button on HyperWorks 2021 GUI and assign the button a function to Extract Elemental Loads
I want to write a script that with a click of a button, can extract loads at particular 1D elements (CBUSH for example) of a FEM that has completed its analysis. I want the loads extracted to a nicely formatted excel file. I am new to TCL scripting so I'm having trouble on where to start. Any suggestions on resources I can have a look at to give me a start?
FYI I am working with HyperWorks 2021.1.
Answers
-
Hi Rahman,
Use attached GUI for your purpose. Add your script with this button.
Regards,
Manoj M.
0 -
Thank you for that code! I want to embed the button into the Ribbon section and have it saved at that location when I open and close the Hyperworks 2021 application. Any ideas on how to do this?
Also another question is the "triggerprocess" supposed to be a stand-in for my code?
0 -
Ibath Rahman said:
Thank you for that code! I want to embed the button into the Ribbon section and have it saved at that location when I open and close the Hyperworks 2021 application. Any ideas on how to do this?
Also another question is the "triggerprocess" supposed to be a stand-in for my code?
They way to accomplish this is through xml and the hmcustom.tcl file.
The hmcustom.tcl file runs during startup and your customization will be loaded every time you open the program if called out in the file. You just need to make sure it is in a default folder (usually the documents folder) or point to it using the HW_CONFIG_PATH environment variable.
I don't have an example readily available of using the xml to add a button to a ribbon but the following article adds a dropdown menu with a similar method.
https://community.altair.com/community?id=kb_article_view&sysparm_article=KB0116948
The ::hwf::ribbonpage add should point to your xml file the defines the ribbon and that xml file can point to your script you want to run when the button is pushed.
0 -
I just created a new blog that goes over adding a button. Please check it out:
https://community.altair.com/community?id=community_blog&sys_id=0c38fa1fdb7401d0cfd5f6a4e296198f
0 -
-
Ben Buchanan said:
I just created a new blog that goes over adding a button. Please check it out:
https://community.altair.com/community?id=community_blog&sys_id=0c38fa1fdb7401d0cfd5f6a4e296198f
https://community.altair.com/community?id=community_blog&sys_id=0c38fa1fdb7401d0cfd5f6a4e296198f
Not working
0 -
Corrado said:
Maybe it wasn't approved yet. Try again, it seems to be working now.
0 -
Ben Buchanan said:
I just created a new blog that goes over adding a button. Please check it out:
https://community.altair.com/community?id=community_blog&sys_id=0c38fa1fdb7401d0cfd5f6a4e296198f
Thanks Ben, that was very helpful. Do you mind also showing an example running the script with the button press? For some reason when I try running your "CreatePropsComp" script with the button press, nothing happens.
0 -
Ibath Rahman said:
Thanks Ben, that was very helpful. Do you mind also showing an example running the script with the button press? For some reason when I try running your "CreatePropsComp" script with the button press, nothing happens.
This one should work with the Add A Button extension.
0 -
Ben Buchanan said:
This one should work with the Add A Button extension.
I took your advice and removed that last procedure call in the script, and I also tried that script you shared. It seems not to work still. I think I may be doing something wrong that is not obvious to me. I have the script in the same directory as the xml files. is this correct?
0 -
Ibath Rahman said:
I took your advice and removed that last procedure call in the script, and I also tried that script you shared. It seems not to work still. I think I may be doing something wrong that is not obvious to me. I have the script in the same directory as the xml files. is this correct?
All this script does is duplicate the property for each component and it selects the component by displayed. So if no components are displayed or you don't have a property assigned it won't do anything.
I would suggest plugging your own script into the extension.xml file and calling your own procedure in the ribbon xml file and test it that way.
0