A web server used to render 3d models from CadQuery code loaded dynamically.
Project description
CadQuery server
A web server used to render 3d models from CadQuery code loaded dynamically.
It has been created for the Cadquery VSCode extension, but can be used as standalone.
Because the CadQuery module is loaded when starting the web server and the scripts are loaded dynamically by request, it has a fast response time.
Example usage in the VSCode extension:
Please note that the web server is intended for personal use and it's absolutely not safe to open it to a public network.
Installation
pip install cq-server
Usage
Starting the server
Once installed, the cq-server
command should be available on your system:
CLI options:
-p
,--port
: Server port (default: 5000);-d
,--dir
: Path of the directory containing CadQuery scripts (default: ".");-m
,--module
: Default module (default: "main");-o
,--object
: Default rendered object variable name (default: "result");
This list might not be up to date, please use -h
to list all options.
Example:
cq-server -p 5000 -d ./examples -m box -o result
This command will run the server on the port 5000
, load the box.py
python file in the ./examples
directory and render the CadQuery model named result
. These two last options can be overridden by url parameters if necessary.
Writing a CadQuery code
Example:
import cadquery as cq
model = cq.Workplane("XY").box(1, 2, 3)
Please read the CadQuery documentation for more details about the CadQuery library.
Using the web server
Once the server is started, go to its url (ie. http://127.0.0.1
).
Optional url parameters:
module
: name of module to load (default: defined in the--module
cli option);object
: variable name of object to render (default: defined in the--object
cli option).
example: http://127.0.0.1?module=box&object=result
).
Note that the /json
endpoint is used internally and can be used for advanced use. It takes same parameters but returns the model as a threejs json object.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cadquery-server-0.2.1.tar.gz
.
File metadata
- Download URL: cadquery-server-0.2.1.tar.gz
- Upload date:
- Size: 301.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0rc2 CPython/3.9.7 Linux/5.13.0-52-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3be9cdb185c9bfb3fece353cc031b74c11aba079901be961353c6eedbb81adb5 |
|
MD5 | 2a90e867b04a4acdca27914eaab35ec7 |
|
BLAKE2b-256 | b9d3f47dfd24a79d963472b3728a8e13f5e83cf6dfa5ee49f3fb4346f077d954 |
File details
Details for the file cadquery_server-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: cadquery_server-0.2.1-py3-none-any.whl
- Upload date:
- Size: 302.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0rc2 CPython/3.9.7 Linux/5.13.0-52-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edba964d4a865ee282d1c51eeb2b9bd8070f952dfe1a8c4b7c4c9bbdd416fd34 |
|
MD5 | e4f973e7426266d75e378e845283d6db |
|
BLAKE2b-256 | 6c2882f20b3214fe370e238d7a3595af0fa0bf86b7817b0f21041d4875fd346e |