Twa29
Aerospace
- Jul 8, 2015
- 2
Hi,
I am relatively new to Python programming in Abaqus. Right now, I am working on a project which will foreseeable grow to quite some size. Therefore I would like to define some reoccurring functions ( def function(): ) and have them in separate files.
First question: What is the best way to do this? Maybe something different than the def function(): stuff?
I am able to load these functions as a module with "from xxx import function", but for this I need to temporarily append the "sys.path", where I need the absolute path to where this file is situated. The files will always be in the same folder or a subfolder of the main file, but not necessarily always in like "C:\\script".
Now, my solution would be to obtain the path from where the script is loaded. But with all functions I found so far, I was not able to get this path. Abaqus only gave me working directories, plugin folders or where Abaqus itself is running.
Does anyone know of a way to get the path from where the script is loaded? Or any other way to use functions which are defined in another file?
Kind regards
I am relatively new to Python programming in Abaqus. Right now, I am working on a project which will foreseeable grow to quite some size. Therefore I would like to define some reoccurring functions ( def function(): ) and have them in separate files.
First question: What is the best way to do this? Maybe something different than the def function(): stuff?
I am able to load these functions as a module with "from xxx import function", but for this I need to temporarily append the "sys.path", where I need the absolute path to where this file is situated. The files will always be in the same folder or a subfolder of the main file, but not necessarily always in like "C:\\script".
Now, my solution would be to obtain the path from where the script is loaded. But with all functions I found so far, I was not able to get this path. Abaqus only gave me working directories, plugin folders or where Abaqus itself is running.
Does anyone know of a way to get the path from where the script is loaded? Or any other way to use functions which are defined in another file?
Kind regards