0

I am creating a bunch of add-ins for Revit using pyRevit, and it is simple to use. I am not that new to python so I have successfully imported many classes with its method in other projects so I could avoid repeated code, etc.

I am trying to do the same in pyRevit but no success.

What I would like to do is to create something in an upper folder and import its methods when needed.

something like:

|Main Folder
|- methoslibrary.py
|- option1.psuhbutton
|--   script.py
|--   icon.png
|- option2.psuhbutton
|--   script.py
|--   icon.png
|- option3.psuhbutton
|--   script.py
|--   icon.png

and access all the methods from methoslibrary.py from their children's script.py files.

I am trying to import the file with a:

from main.methoslibrary import *

from one of the script files but no success, even though this works for other python projects.

Any ideas? Should I change any config?

  • 1
    pyRevit bundles can have a `lib/` directory. The path to this directory is automatically added to the `sys.path` so you can import your modules. see https://www.notion.so/pyrevitlabs/pyRevit-Bundles-12323e3090904d9aa7cdc3d82095d3e3#32c67ca843c84d0684ea7f7e876b9737 – Ehsan Iran-Nejad Oct 29 '19 at 15:38
  • 1
    I see! Thanks a lot, I will try it shortly, this will save me a lot of time! – Lucas Moreira Oct 30 '19 at 18:20

0 Answers0