Modules in python Cadwork plugin #118
-
I am trying to organize my python plugin into modules. Ideally having a minimal "PLUGIN_NAME.py" that just call logic defined in subfolders. import time
print("sandbox start")
from Sandbox import TestObject
TestObject.Display()
print("sandbox end")
time.sleep(1)
print("bye")
time.sleep(1) Running SUS_Sandbox.py prints results as expected. But running it in Cadwork leads to import issues : Anyclue how to solve my imports ? edit : added code : SUS_Sandbox.zip |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Die you import "Sandbox" (which is a submodule) in the init of the main package ? |
Beta Was this translation helpful? Give feedback.
-
Hi @usai-sylvain See => https://docs.cadwork.com/projects/cwapi3dpython/en/latest/modules/ import sys
import cadwork
import element_controller
import utility_controller as uc
plugin_path = uc.get_plugin_path()
path_parts = [plugin_path , '.venv', 'Lib', 'site-packages']
path = '/'.join(path_parts)
sys.path.append(path)
import sandbox... |
Beta Was this translation helpful? Give feedback.
-
this works https://github.com/Brunner246/cwapi3d_examples/blob/master/github_questions/SUS_Sandbox.py |
Beta Was this translation helpful? Give feedback.
@usai-sylvain
this works https://github.com/Brunner246/cwapi3d_examples/blob/master/github_questions/SUS_Sandbox.py