|
PythonOCC环境配置#OCC7.5.1condacreate--name=pyoccenvpython=3.7sourceactivatepyoccenvcondainstall-cconda-forgepythonocc-core=7.5.1#OCC7.7.0condacreate--name=pyoccenvpython=3.9activatepyoccenvcondainstall-cconda-forgepythonocc-core=7.7.012345678完成后需要安装一个pyside界面或者pyqt来使用pyocc库的样例代码,这里我们推荐安装官方的pyside#pyside环境activatepyoccenv_pysidepipinstallpyside2-ihttps://pypi.douban.com/simple/#pyqt环境activatepyoccenv_pyqtpipinstallPyQt5-tools-ihttps://pypi.douban.com/simple123456首先看PyQt5是否安装成功。importsysfromPyQt5.QtCoreimport*fromPyQt5.QtGuiimport*fromPyQt5.QtWidgetsimport(QApplication,QLabel)#CreateaQtapplicationapp=QApplication(sys.argv)#CreateaLabelandshowitlabel=QLabel("HelloWorld")label.show()#EnterQtapplicationmainloopapp.exec_()sys.exit()12345678910111213141516看pyside是否安装成功importsysfromPySide2.QtWidgetsimportQApplication,QLabel#创建一个Qt应用app=QApplication(sys.argv)#创建一个标签并显示它label=QLabel("HelloWorld")label.show()#进入Qt应用主循环app.exec_()sys.exit()12345678910111213再看pyocc是否能够运行建立文件pyocc_test.py#pyocc_test.py#第一个程序,在显示框中显示两个点fromOCC.Display.SimpleGuiimportinit_displayfromOCC.Core.gpimportgp_Pntif__name__=='__main__':display,start_display,add_menu,add_function_to_menu=init_display()P0=gp_Pnt(0,0,1)P1=gp_Pnt(0,30,20)display.DisplayShape(P0)display.DisplayShape(P1)start_display()1234567891011
|
|