Hello Matt,
I wanted to thank you and Klaus for the interesting webinar today! I noticed a few things, while watching it, that have already caused me many headaches. Therefore, I want to share my insights on how to avoid unnecessary frustration!
My experience is, that it is not a good idea to extend the sys.path
of an external Python Interpreter with the path to the Cubit modules like it is shown in create_mesh.py
! This is because you have to make sure, that your Python interpreter is a 100% binary compatible with Cubit’s interpreter (i.e. Python minor version, OS, bitness, UCS2 vs. UCS4 strings, etc.). And even if that is the case, other binary Python packages (like e.g. VTK) can still cause the external interpreter to crash due to incompatible DLLs when imported at the same time!
The background is, that the Cubit Python package is still implemented (at least in 2022) as a binary wrapper around the Cubit runtime. And mixing too many runtimes inside the adress space of a single process, namely in that of Python, is never a good idea! The bottom line of this is, that Cubit forces you to use a certain version of the Python interpreter. If you e.g. need a second package in your workflow, that depends on a different version of Python you are screwed!
In my opinion, extending the sys.path
is okay, as long as you just want to do some quick-and-dirty trials. But if you want to create stable workflows that need to keep working for the years to come, you absolutely cannot depend on the binary compatibility of the Cubit Python modules with a given arbitrary external Python interpreter! This is because you have absolutely no control over what Python interpreter Cubit will use in the future (Python 2.7, 3.6, 3.8, who but Coreform knows that??!).
For the moment I suggest, that one rather just uses the features, that are available in the Python interpreter inside Cubit. You can then start all your Cubit-related Python tasks using Cubit’s batch interface:
coreform_cubit -batch -nographics -nojournal -nooverwritecheck my_cubit_script.py
For the future, I would really find it helpful, if Cubit could provide the scripting interface to Python e.g. in a client/server based way. This way, it would not be necessary anymore to mix binary runtimes inside an external Python interpreter.
The other suggestion I wanted to make concerning advanced APREPRO scripting was about the SurfaceAt()
APREPRO function. It comes in handy, if you do not have full control over the geometry (maybe you imported it from a STEP file) and need to find out surface ids based on coordinate positions:
https://coreform.com/cubit_help/appendix/aprepro/aprepro_functions.htm
create volume loft surface {SurfaceAt(0, 0, 0.73, 2)} {SurfaceAt(0, 0, 0.731, 1)}
I also found the more general Sandia APREPRO manual quite helpful:
https://gsjaardema.github.io/seacas-docs/aprepro.pdf