tpaviot / pythonocc-core

Python package for 3D geometry CAD/BIM/CAM
GNU Lesser General Public License v3.0
1.33k stars 374 forks source link

Connecting pythonocc 3D viewing window to the PyQt5 UI #574

Open jhha2445 opened 5 years ago

jhha2445 commented 5 years ago

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()
dongpipi commented 5 years ago

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!

qunat commented 4 years ago

I can help you i can supply an example to you

HerveGlz commented 4 years ago

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.

adam-urbanczyk commented 4 years ago

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

HerveGlz commented 4 years ago

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.

Tanneguydv commented 2 years ago

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

qunat commented 1 year ago

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