Hypermesh Python problem

Hello,
I'm trying to learn python in order to make script that I can use in hypermesh. I have a script with an input command (ID_node = input("\nEnter the ID of a node :\n \n")
If I run this script with :
file → load → python script, Hypermesh crashes
but if I type the command directly in the Hypermesh python window, i can feed the input normally, does anybody know why ?
Best regards, Thomas
Answers
-
Hi Adam,
Thank you for your answer
It's not the only line in my script but i find that it's this one that cause problem.
So in my debug script, yes i only have this line. For the version, I use Hypermesh 2024.1, with optistruct solver.
Python version in the Hypermesh python window : Jupyter QtConsole 5.1.1
| Python 3.8.10Best regards
0 -
Hi @Thomas_D,
Here is an alternative approach you may want to use:
I have a model with an example material, MAT1, where I want to change its Young's Modulus (E). By loading in this Python script, it will create a message window that the User can enter in a material ID (1, in this case) and then the script will update E to 210999.0 for that material. Here is the syntax:
#####################################################################
#Message Window Example
##################################################################### #Import hypermesh library
import hm
import hm.entities as ent #Import messagebox (tkinter) library
from tkinter import *
from tkinter.simpledialog import askstring
from tkinter.messagebox import showinfo #Create an instance of tkinter frame and window
win=Tk()
win.geometry("700x300") #Create a message window that asks for an input
matID = askstring('Material Change', 'What Material Do You Want to Change?') #Force destory the tkinter main window
win.destroy() #Get model information
myModel = hm.Model()
myMat = ent.Material(myModel,int(matID)) #Use the input to change the material property
myMat.E = 210999.0To test this out, simply open the mat1_test.hm model in HyperMesh and then File » Load » Python Script » hypermesh_change_material_rev00.py
Hope this helps!
Adam Reid
0 -
Hi @Thomas_D,
if you want to modify e.g. the .fem files you could also try using Synera - a low-code software to automate HyperMesh or OptiStruct e.g. for modifying decks or automating the pre-processing with setting geometric rule-based boundary conditions.
It might be easier then scripting as there are some specific features to adapt OptiStruct cards. The software is part of the Altair Partner Alliance, so you can easily download it and give it a try: https://altair.com/synera
Here you can find some examples and see how it works:
0