Automatically open an introductory example when the user choses the CadQuery workbench.
This commit is contained in:
parent
79f896bd0a
commit
943845df91
17
CadQuery/Examples/Ex000_Introduction.py
Normal file
17
CadQuery/Examples/Ex000_Introduction.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# This example is meant to be used from within the CadQuery module of FreeCAD.
|
||||||
|
# From within FreeCAD, you can make changes to this script and then click
|
||||||
|
# CadQuery > Execute Script, or you can press F2.
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
# The dimensions of the box. These can be modified rather than changing the
|
||||||
|
# box's code directly.
|
||||||
|
length = 2.0
|
||||||
|
height = 1.0
|
||||||
|
thickness = 1.0
|
||||||
|
|
||||||
|
# Create a 3D box based on the dimension variables above
|
||||||
|
result = cadquery.Workplane("XY").box(length, height, thickness)
|
||||||
|
|
||||||
|
# Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
|
@ -35,6 +35,7 @@ class CadQueryWorkbench (Workbench):
|
||||||
import os, sys
|
import os, sys
|
||||||
from PySide import QtGui, QtCore
|
from PySide import QtGui, QtCore
|
||||||
import module_locator
|
import module_locator
|
||||||
|
from Gui import ImportCQ
|
||||||
|
|
||||||
#Set up so that we can import from our embedded packages
|
#Set up so that we can import from our embedded packages
|
||||||
module_base_path = module_locator.module_path()
|
module_base_path = module_locator.module_path()
|
||||||
|
@ -85,7 +86,6 @@ class CadQueryWorkbench (Workbench):
|
||||||
#Only hide the widget if it isn't already hidden
|
#Only hide the widget if it isn't already hidden
|
||||||
if not widget.isHidden():
|
if not widget.isHidden():
|
||||||
widget.setVisible(False)
|
widget.setVisible(False)
|
||||||
#FreeCAD.Console.PrintMessage(widget.objectName())
|
|
||||||
self.closedWidgets.append(widget)
|
self.closedWidgets.append(widget)
|
||||||
else:
|
else:
|
||||||
widget.setVisible(True)
|
widget.setVisible(True)
|
||||||
|
@ -97,17 +97,17 @@ class CadQueryWorkbench (Workbench):
|
||||||
|
|
||||||
#Set up the text area for our CQ code
|
#Set up the text area for our CQ code
|
||||||
server_path = os.path.join(module_base_path, 'cq_server.py')
|
server_path = os.path.join(module_base_path, 'cq_server.py')
|
||||||
# if sys.platform.startswith('win'):
|
|
||||||
# #We have to jump through extra hoops to hand-hold Windows here
|
|
||||||
# server_path = "\"" + server_path + "\""
|
|
||||||
# libs_path = "\"" + libs_path + "\""
|
|
||||||
# FreeCAD.Console.PrintMessage( server_path + ":" + libs_path)
|
|
||||||
codePane = PyCodeEdit(server_script=server_path, interpreter=interpreter, args=['-s', libs_path])
|
codePane = PyCodeEdit(server_script=server_path, interpreter=interpreter, args=['-s', libs_path])
|
||||||
codePane.setObjectName("cqCodePane")
|
codePane.setObjectName("cqCodePane")
|
||||||
|
|
||||||
#Add the text area to our dock widget
|
#Add the text area to our dock widget
|
||||||
cqCodeWidget.setWidget(codePane)
|
cqCodeWidget.setWidget(codePane)
|
||||||
|
|
||||||
|
#Open our introduction example
|
||||||
|
example_path = os.path.join(module_base_path, 'Examples')
|
||||||
|
example_path = os.path.join(example_path, 'Ex000_Introduction.py')
|
||||||
|
ImportCQ.open(example_path)
|
||||||
|
|
||||||
def Deactivated(self):
|
def Deactivated(self):
|
||||||
from Gui import ExportCQ
|
from Gui import ExportCQ
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user