pythonocc-core icon indicating copy to clipboard operation
pythonocc-core copied to clipboard

Connecting pythonocc 3D viewing window to the PyQt5 UI

Open jhha2445 opened this issue 7 years ago • 7 comments

Hi, I'm trying to connect the pythonocc 3D view to PyQt5 UI. I have a PyQt widget window as below, and I want to make it so that if I press the 'PushButton', my pythonocc 3D view would pop up in the square with a name 'label1' to the bottom of the PushButton.

image

If you could help me to show the simple filet, generated from the code below, in the box 'label1', that would be really much appreciated. I'm kind of new to all this, and i've been struggling with this problem for quite a bit now, and I couldn't find much info anywhere either... Thanks in advance.

from OCC.gp import gp_Pnt,gp_Dir,gp_Pln
from OCC.Display.SimpleGui import init_display
from OCC.ChFi2d import ChFi2d_AnaFilletAlgo
from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge,BRepBuilderAPI_MakeWire

from core_geometry_utils import make_wire
display,start_display, add_menu,add_functionto_menu = init_display()

p1 = gp_Pnt(0, 0, 0) 
p2 = gp_Pnt(5, 5, 0)
p3 = gp_Pnt(-5,5, 0)

ed1 = BRepBuilderAPI_MakeEdge(p3,p2).Edge()
ed2 = BRepBuilderAPI_MakeEdge(p2,p1).Edge()

f = ChFi2d_AnaFilletAlgo()
f.Init(ed1,ed2,gp_Pln())
radius = 1.0
f.Perform(radius)
fillet2d = f.Result(ed1,ed2)

w = make_wire([ed1, fillet2d, ed2])
display.DisplayShape(w)
start_display()

jhha2445 avatar Nov 10 '18 09:11 jhha2445

Sorry that im not good at PyQt... Could you please tell me what module 'core_geometry_utils' is? I didnt find it in pythonocc 0.18.1. Thanks!

dongpipi avatar Nov 29 '18 05:11 dongpipi

I can help you i can supply an example to you

qunat avatar Feb 14 '20 18:02 qunat

I can help you i can supply an example to you

Hi @qunat , will it be possible to share it to the community here so that we can understand how to do it as well ? Since I am interested in this topic too. Thanks in advance for your help.

HerveGlz avatar Mar 27 '20 11:03 HerveGlz

Here you can find an example of integrating PythonOCC into a medium size PyQt5 application: https://github.com/CadQuery/CQ-editor @HerveGlz

adam-urbanczyk avatar Mar 27 '20 17:03 adam-urbanczyk

Here you can find an example of integrating PythonOCC into a medium size PyQt5 application: https://github.com/CadQuery/CQ-editor @HerveGlz

Thanks a lot @adam-urbanczyk It seems to be a great example to discover how to do it and at the same time a nice pythonocc based application to play with.

HerveGlz avatar Mar 29 '20 17:03 HerveGlz

there's an example of integration here : https://github.com/tpaviot/pythonocc-demos/blob/master/examples/core_display_qt5_app.py

I guess we could close the issue

Tanneguydv avatar Sep 16 '22 13:09 Tanneguydv

you can refer the project https://github.com/qunat/Pythonocc-CAD

qunat avatar Dec 06 '22 23:12 qunat