Repository navigation
Modules in python Cadwork plugin #118
Answered
by
Brunner246
usai-sylvain
asked this question in
Q&A
|
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 |
Answered by
Brunner246
Jan 24, 2024
Replies: 3 comments 5 replies
|
Die you import "Sandbox" (which is a submodule) in the init of the main package ? |
1 reply
|
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... |
1 reply
|
this works https://github.com/Brunner246/cwapi3d_examples/blob/master/github_questions/SUS_Sandbox.py |
3 replies
Answer selected by
usai-sylvain
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment





@usai-sylvain
this works https://github.com/Brunner246/cwapi3d_examples/blob/master/github_questions/SUS_Sandbox.py