I'm afraid that pyautocad is not supported, but....
Locally speaking (there is already an answer for server side working) -
There are some interesting things about pyscript and local modules.
In subfolder modules there are two files: hello_module.py
and byby_module.py
.
hello_module.py
is:
def hello():
return '***** **** ** * Hello World * ** **** *****'
byby_module.py
is:
def byby():
return '***** **** ** * ByBy World * ** **** *****'
There is also the main.py
in index folder calling functions from local subfolder modules.
main.py
is:
pyscript.write("output", 'T E S T I N G', True)
pyscript.write("output", hello(), True)
pyscript.write("output", byby(), True)
index.html
is:
<html>
<head>
<title>Test</title>
<!-- <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js" onerror=scriptLoadFailure('pyscr ipt.js')></script> -->
<link rel="stylesheet" href="pyscript.css" />
<script defer src="pyscript.js"></script>
<py-env>
paths
./modules/hello_module.py
./modules/byby_module.py
./main.py
</py-env>
</head>
<body>
<py-script src="./modules/hello_module.py"></py-script>
<py-script src="./modules/byby_module.py"></py-script>
<py-script src="main.py"></py-script>
<div id="output"></div>
</body>
</html>
Above example code works(!)
and shows that we can use local modules. There are a lot of questions and considerations to take care of and a lot of "What Ifs" like what if we have the same function name in both modules etc, etc....
On the contrary if main.py
is removed from py-env node and from src attribute moving all the very same commands from file into py-script node of html then it fails!?
py-env
and py-script
part of html that fails looks like this:
<py-env>
paths
./modules/hello_module.py
./modules/byby_module.py
</py-env>
<py-script src="./modules/hello_module.py"></py-script>
<py-script src="./modules/byby_module.py"></py-script>
<py-script>
pyscript.write("output", 'T E S T I N G', True)
pyscript.write("output", hello(), True)
pyscript.write("output", byby(), True)
</py-script>
The error is:
File "", line 2, in NameError: name 'hello' is not defined
It means (does it?!) that we can call local functions from different local modules but not from within html pyscript code which (the second part) is just as it is expected to be. If the same code is within the local .py file and declared as src attribute in html then it works.