CadQuery / CQ-editor

CadQuery GUI editor based on PyQT
Apache License 2.0
757 stars 116 forks source link

Launch Viewport from python script #410

Closed rohit-kumar-j closed 1 year ago

rohit-kumar-j commented 1 year ago

I'm not sure if there is an issue on this, but ...

Is there a way to launch only a viewport only showing parts of the GUI from within a python script?... without the toolbars, and other viewports and controls?

Something Like this:

import cadquery as cq

length = 80.0 
height = 60.0  
thickness = 10.0

result = cq.Workplane("XY").box(length, height, thickness)

# Adding an option like this, opens a simple opengl viewer with the regular mouse movements
show_object(result, independent_viewport=true)

Instead of this:

rohit-kumar-j commented 1 year ago

Reason: I use neovim for programming, and do not want to switch to the full fledged editor. Setting up break points could be done outside the editor from within neovim's debugger.

I would be glad to contribute a plugin for this,😄,... if anyone would guide me through cadquery's api, as I do not want to dig deep into cad query itself, and this is the first time working with PyQt

jmwright commented 1 year ago

This is in the newer commits of CadQuery.

https://github.com/CadQuery/cadquery/pull/1366

rohit-kumar-j commented 1 year ago

Is there a particular stable commit hash?

It opens a window but with errors:

Successfully installed cadquery-2.4.0.dev0
PS C:\Koala\python\cadquery> python .\quick_window.py
2023-08-28 00:52:13.855 (  10.266s) [                ]vtkDemandDrivenPipeline:663    ERR| vtkCompositeDataPipeline (000001EF59A41FA0): Input port 0 of algorithm vtkTriangleFilter (000001EF5A129C40) has 0 connections but is not optional.
Traceback (most recent call last):
  File "C:\Koala\python\cadquery\quick_window.py", line 9, in <module>
    show(result)
  File "C:\Users\jsk71\AppData\Local\Programs\Python\Python311\Lib\site-packages\cadquery\vis.py", line 82, in show
    win.SetSize(*win.GetScreenSize())
TypeError: vtkRenderWindow.SetSize() argument after * must be an iterable, not NoneType
PS C:\Koala\python\cadquery>

Code:

import cadquery as cq
from cadquery.vis import show

d = 10  # box is visible as expected
# d = 100  # empty window displayed; after 'r' key or zoom with middle mouse the box is displayed

result = cq.Workplane().box(d, d, d)

show(result)
rohit-kumar-j commented 1 year ago

Let me mention it in https://github.com/CadQuery/cadquery/pull/1366