diff --git a/CadQuery/Examples/Ex000_Introduction.py b/CadQuery/Examples/Ex000_Introduction.py new file mode 100644 index 0000000..e4fa87f --- /dev/null +++ b/CadQuery/Examples/Ex000_Introduction.py @@ -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()) diff --git a/CadQuery/InitGui.py b/CadQuery/InitGui.py index 5a5c324..3e1b19a 100644 --- a/CadQuery/InitGui.py +++ b/CadQuery/InitGui.py @@ -35,6 +35,7 @@ class CadQueryWorkbench (Workbench): import os, sys from PySide import QtGui, QtCore import module_locator + from Gui import ImportCQ #Set up so that we can import from our embedded packages module_base_path = module_locator.module_path() @@ -85,7 +86,6 @@ class CadQueryWorkbench (Workbench): #Only hide the widget if it isn't already hidden if not widget.isHidden(): widget.setVisible(False) - #FreeCAD.Console.PrintMessage(widget.objectName()) self.closedWidgets.append(widget) else: widget.setVisible(True) @@ -97,17 +97,17 @@ class CadQueryWorkbench (Workbench): #Set up the text area for our CQ code 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.setObjectName("cqCodePane") #Add the text area to our dock widget 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): from Gui import ExportCQ