×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Abaqus Python load module from external file

Abaqus Python load module from external file

Abaqus Python load module from external file

(OP)
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


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources