Giter VIP home page Giter VIP logo

Comments (17)

bernhard-42 avatar bernhard-42 commented on May 24, 2024 1

It behaves pretty strange:

I start with

l = 1
w = 2
h = 3

Then I change l, save, change w, save and change h and save. Looks good up to now.
However, when I press save then without changes, the view show kind of a random view of the four views I have created with my process, see animated gif, where I just press save before the view changes.

error

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024 1

One way to overcome the latency is to use "shift-enter" approach in VS Code.
Instead of just saving (very convenient with cadquery-server), one could use Ctrl-A + Shift-Enter (or Cmd-A + Shift-Enter on the Mac). This will incrementally run the code in VS Code in the attached Python interpreter.
Not as easy as your cadquery-server approach, but no exec needed and same speed. Additionally, one could leverage pre-calculated objects by reusing the variables and just selecting the rest of the code before pressing Shift Enter.
Again, no optimal solution, however you had asked about ideas how to avoid the import latency.

However, both the "cadquery-server" and the "shift-enter" approach do not allow step-by-step debugging.

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024 1

At least from a debugging perspective, I don't feel that the import cadquery is a big issue (at least on my laptop, which admittedly is a fast machine)

debug

Also a "Run without Debugging" is really fast on my laptop:

run

Given that experience, on my laptop I definitely would prefer to work without cadquery-server and be able to properly
debug my code step by step

from cadquery-vscode.

roipoussiere avatar roipoussiere commented on May 24, 2024

It should be fixed in the last version of pip package / docker image. Do you want to give a try?

from cadquery-vscode.

roipoussiere avatar roipoussiere commented on May 24, 2024

I cannot not reproduce this. Do you use the docker version of cadquery-server or the pip one?

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024

I use pip. I anyhow have cadquery installed and don't need the whole docker infrastructure on my Mac

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024

... and the pip version allows to load step files. Not sure this is supported with docker where the interpreter runs in the container

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024

It would be great if you could get rid of the server component. My viewer approach uses zmq. There is a version for Javascript: https://github.com/zeromq/zeromq.js It seems that the server component in javascript or typescript running in VS Code can receive messages from python zmq lib.
Then one would only need a show function that does the tessellation and then sends the tessellated arrays via zmq to VS Code.
Just an idea, since for me the server component is as inconvenient as my approach with the separate viewer.
And, with the zmq approach, one could use the Python debugger in VS Code to do step-by-step debugging of the code and every now and then call show to check the interims results.
Just my 2 cent ...

from cadquery-vscode.

roipoussiere avatar roipoussiere commented on May 24, 2024

I use pip. I anyhow have cadquery installed and don't need the whole docker infrastructure on my Mac

Yes, this is totally legit, I just want to understand how to reproduce the bug, I don't have it on the docker version.

Then one would only need a show function that does the tessellation and then sends the tessellated arrays via zmq to VS Code.

The solution with zmq is interesting. I made the choice of the server part because of these two benefits:

  • avoid complex installation: for many end-users, installing cadquery can be difficult, so I liked the idea to run a docker container that "just work";
  • reduce the rendering delay: since the cadquery server already loaded the cadquery module.

The first point could be eventually solved with CadQuery/cadquery#1048.
I don't see how to adress the second point with the zmq architecture. Do you?

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024

avoid complex installation

I agree, installing CadQuery is not always fun. I have spent quite some time on it in the past. So the docker approach is good, but is a little bit inflexible: CadQuery doesn't have a short term release strategy (2.1. is more than 1 year old and everyone works with the latest master) and with your docker container I am restricted to the version you provide. I cannot quickly pip install the git repo (If OCP doesn't change, pip of Cadquery repo is sufficient).

By the way, can I load e.g. step files with the docker version? Or save STL results for my 3d printer?

I personally don't really trust the exec approach in Python due to the locals, globals handling. To me it feels like one can mess up things easily with unclear side effects. Maybe it is just because I don't understand it enough ...

reduce the rendering delay: since the cadquery server already loaded the cadquery module.

I understand this issue. I solved it in my workflow by working in Jupyter. I import cadquery only once for a session and even better, really complex interims results can be calculated once and then used in the cells below without recalculation. Big benefit for my workflows. I don't want to open the IDE vs. Notebook discussion. Just explain my approach to avoid the loading times (latency is an issue in general, so my latest version of Jupyter CadQuery - nearly ready - will have caching for bounding box calculations and tessellation results and uses multiprocessing for large CAD assemblies. That is a much bigger performance booster than avoiding the import of cadquery. Note this is only available in Jupyter-CadQuery not in three-cad-viewer).

But agreed, it is a difficult decision, and one has to go one route ...

from cadquery-vscode.

roipoussiere avatar roipoussiere commented on May 24, 2024

By the way, can I load e.g. step files with the docker version? Or save STL results for my 3d printer?

Yes, using a docker volume: docker run --rm -d -v $(pwd):/home/cq -p 5000:5000 cadquery/cadquery-server, but I agree it's not very practical. But anyway cadquery can now be installed with pip, so the use of docker is not really necessary.

I agree that the server and exec approach is not perfect.

I could eventually give the choice between using the cadquery server or not.

from cadquery-vscode.

roipoussiere avatar roipoussiere commented on May 24, 2024

I made some work on this!

It consists on a huge change on the cadquery-server behavior.

The exec approach is not used anymore, instead the server executes the CadQuery code and renders the model using three-cad-viewer. Finally, it includes a file watcher that reloads the Python code and update the web page when the file is updated:

cq-server_v0-2-1_demo.webm

This approach allows to debug the code in VSCode.
It also makes the project compatible with any IDE and any web browser.
And also allow a user to display the model in an other screen, or even in an other computer on the same local network.

In VSCode, the web page can be displayed using LivePreview extension (ctrl+shift+P -> Simple Browser: Show).
This might turn the whole VSCode extension deprecated, as all the job is made by cq-server.

I moved it in a dedicated repository and can be installed with pip install cadquery-server (it doesn't include cadquery itself, which is an extra-dependency).

Do you want to give a try? :)

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024

Hi @roipoussiere
having been away on vacation for the last two weeks, I how wanted to give it a try.
Unfortunately minify-html 0.10.0 doesn't seem to exist for Mac M1, only 0.9.2.
So I haven't managed to install it. Is 0.10.0 necessary?

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024

wilsonzlin/minify-html@29e7b1c doesn't sound promising

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024

Cloned it and gave it a try:

  • On a Mac, port 5000 is used by ControlCenter, hence I use -p parameter
  • Somehow on my machine it doesn't detect code changes. I use a file test.py and started with cq-server -p 5001 -m test.py. However, when I change and save test.py nothing happens and I have to refresh the browser
  • I don't understand how I could use step-by-step debugging in VS Code

from cadquery-vscode.

roipoussiere avatar roipoussiere commented on May 24, 2024

So I haven't managed to install it. Is 0.10.0 necessary?

I think you can use minify html 0.9.2. And it's only used for export when --minify option is passed to cli.

I don't understand how I could use step-by-step debugging in VS Code

In fact I realized it's not possible currently, the issue has been reported here: roipoussiere/cadquery-server#27. The idea is to actually execute the script when using the debugger, instead of reloading it using cq-server.

from cadquery-vscode.

bernhard-42 avatar bernhard-42 commented on May 24, 2024

@roipoussiere Just for information:
The main reason for me to switch to and IDE like VSCode is step-by-step debugging. I have now created my own VSCode extension, which is loosely coupled between Python and the Typescript VSCode extension: The extension starts a web server on port 3939 and the Python show command sends tessellated objects to this web server via HTTP POST. No external server that needs to be run separately.

  • The CadQuery viewer extension for VS Code can be installed from a vsix file and started via "Ctrl-k v" / "Cmd-k v" (check CadQuery settings in VS Code)
  • The show command can be installed by installing a wheel, show_object would need to be improved (args)

Both vsix and wheel can be found in https://github.com/bernhard-42/vscode-cadquery-viewer/releases at the moment.

This gif shows both, using "Run in Python Terminal" (very fast for small experimental code snippets) and proper "Debugging" with VSCode debugger:

cq-vscode

from cadquery-vscode.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.