roipoussiere / cadquery-vscode Goto Github PK
View Code? Open in Web Editor NEWBuild parametric 2D/3D CAD models in VSCode with the CadQuery library.
Home Page: https://open-vsx.org/extension/roipoussiere/cadquery
License: MIT License
Build parametric 2D/3D CAD models in VSCode with the CadQuery library.
Home Page: https://open-vsx.org/extension/roipoussiere/cadquery
License: MIT License
exec
fails with simple (an natural) approaches:
import cadquery as cq
l = 1
w = 2
h = 3
def box():
return cq.Workplane().box(l, w, h).edges().fillet(0.1)
show(box())
fails with
File "<string>", line 9, in box
NameError: name 'cq' is not defined
So let's change it (just for the test, I would never program like that):
l = 1
w = 2
h = 3
def box():
import cadquery as cq
return cq.Workplane().box(l, w, h).edges().fillet(0.1)
show(box())
Now, this fails with
File "<string>", line 9, in box
NameError: name 'l' is not defined
exec
just doesn't play well with global variables
Of course, this works:
def box(l=1, w=2, h=3):
import cadquery as cq
return cq.Workplane().box(l, w, h).edges().fillet(0.1)
show(box())
However I would need to adapt my style of coding - especially for quick hacks - to the limitations of exec.
Maybe there is a more robust way?
This project is going to be replaced by cadquery-server: https://github.com/roipoussiere/cadquery-server
It can be used with VSCode and have many useful features, please give a try. :)
Hi ,
first i am very new to CAD so excuse my bug report if i made something wrong....
import cadquery as cq
res = cq.Workplane("front").box(50, 50, 50)
res = res + cq.Workplane("front").text("Front", 8, 26)
res = res + cq.Workplane("back").text("Back", 8, 26)
res = res + cq.Workplane("top").text("Top", 8, 26)
res = res + cq.Workplane("bottom").text("Bottom", 8, 26)
res = res + cq.Workplane("left").text("Left", 8, 26)
res = res + cq.Workplane("right").text("Right", 8, 26)
res = res.rotate((0, 0, 0), (1, 0, 0), 90) # Rotates the object 90 degree down so it works without touching in Cura Slicer and Super Slicer
cq.exporters.export(res, "test.step")
cq.exporters.export(res, "test.stl")
res = res.rotate((0, 0, 0), (1, 0, 180), 90)
show(res)
The rotate before exporting step and stl is required so it is aligned with 3d printer slicers.
The rotate before the show is required so i dont have to use the mouse to view to click on it.... so it looks good...
This puts everything in a good perspective....
The only problem is the LEFT/RIGHT are opposing.... (TOP, BOTTOM, FRONT, BACK are working correctly)
I have installed CadQuery locally and then I get great code completion and syntax help on hovering.
See bernhard-42/jupyter-cadquery#78
Typos, wrong API use, ... will just be hidden behind the cadquery server.
Can this be surfaced in some VS Code output model?
Hi roipoussiere
I have been using OpenSCAD in VSCodium for a while now, however, as my models become more complex, I am running into performance issues, so I decided to give CadQuery a whirl. I followed your instructions provided and when I tried to start cq-server from the terminal it would not start...
As my programming skills are wildly dangerous at best, I am unsure how to proceed. I have thought of following the installation instructions on the CadQuery2 wiki, but would prefer to use VSCodium and preview my files there. I am using a Lenovo Thinkpad X1 Tablet running Fedora 36, Gnome 42, Python 3.10.5 and the latest version of VSCodium. I deleted the venv folder and retried in case I had messed something up. I know that Fedora 36 changed some of the site package installation directories, but I assumed the virtual environment thing would avoid any issues.
Any help resolving this issue would be greatly appreciated.
Thanks
Dorian
On bigger screens, all menu items easily fit onto the screen.
Would be great if the extension would check the cad view width and decide to hide elements or not
The next Jupyter-Cadquery will come with multiprocessing support for large assemblies.
This doesn't work well with flask. I made it run by forcing imports (initializing multiprocessng) being done after start of flask:
import cadquery
from flask import Flask, request
app = Flask(__name__)
json_result = "[{}, {}]"
def show(model):
global json_result
from jupyter_cadquery.utils import numpy_to_json
from jupyter_cadquery.cad_objects import to_assembly
from jupyter_cadquery.base import _tessellate_group
json_result = numpy_to_json(_tessellate_group(to_assembly(model)))
@app.route("/", methods=["GET", "POST"])
def root():
if request.method == "GET":
return "Please send a CadQuery Python script in a POST request.\n"
elif request.method == "POST":
exec(request.get_data().decode())
return json_result
def run():
app.run(host="0.0.0.0", port=4999, debug=False)
Is this something you could change?
Hello, I've tried your extension on Windows and when I want to open the viewer I get this error msg :
Une erreur système s'est produite (ENOENT: no such file or directory, open '/c:/Users/Romain/.vscode/extensions/roipoussiere.cadquery-0.1.2/static/cq-viewer.html')
The problem is due to the first slash before the c:/, the file is actually in the right location, the path is just corrupted due to the linux slash used here.
For example, when I type:
obj = cq.Workplane('front').box(1,2,3)
the code completion works well. But when adding more dots, such as :
obj = cq.Workplane('front').box(1,2,3).faces('>Z').workplane().hole(0.2)
all the following up methods can not activate code completion.
I am using VSCode v1.71.1 on Windows 10 1809 LTSC, and this plugin is of version 0.1.3 which is the latest.
By the way, I only use this plugin as a CADQuery code completion plugin in VSCode for easily writing .py file. The 3D object is simutaniously being rendered in CQ-Editor by Autoreload function.
The installation says: source venv/bin/activate, but there is no "source" command on Windows and the path separator is a ''
On a Mac port 5000 is used and I don't want to turn the respective service off.
And sometimes I'd like to also control the host variable. 0.0.0.0
is pretty broad.
So support for cq-server --host 0.0.0.0 --port 4999
or cq-server -h 0.0.0.0 -p 4999
would be highly appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.