def Activated(self): # So we can open the "Open File" dialog mw = FreeCADGui.getMainWindow() # Try to keep track of the previous path used to open as a convenience to the user if self.previousPath is None: # Start off defaulting to the Examples directory module_base_path = module_locator.module_path() exs_dir_path = os.path.join(module_base_path, 'Examples') self.previousPath = exs_dir_path filename = QtGui.QFileDialog.getOpenFileName( mw, mw.tr("Open CadQuery Script"), self.previousPath, mw.tr("CadQuery Files (*.py)")) # Make sure the user didn't click cancel if filename[0]: self.previousPath = filename[0] # Append this script's directory to sys.path sys.path.append(os.path.dirname(filename[0])) # We've created a library that FreeCAD can use as well to open CQ files ImportCQ.open(filename[0])
def Activated(self): FreeCAD.Console.PrintMessage(self.exFile + "\r\n") #So we can open the "Open File" dialog mw = FreeCADGui.getMainWindow() #Start off defaulting to the Examples directory module_base_path = module_locator.module_path() exs_dir_path = os.path.join(module_base_path, 'Examples') #We need to close any file that's already open in the editor window CadQueryCloseScript().Activated() #Append this script's directory to sys.path sys.path.append(os.path.dirname(exs_dir_path)) #We've created a library that FreeCAD can use as well to open CQ files ImportCQ.open(os.path.join(exs_dir_path, self.exFile)) docname = os.path.splitext(os.path.basename(self.exFile))[0] FreeCAD.newDocument(docname) #Execute the script CadQueryExecuteScript().Activated() #Get a nice view of our model FreeCADGui.activeDocument().activeView().viewAxometric() FreeCADGui.SendMsgToActiveView("ViewFit")
def Activated(self): module_base_path = module_locator.module_path() templ_dir_path = os.path.join(module_base_path, 'Templates') # Use the library that FreeCAD can use as well to open CQ files ImportCQ.open(os.path.join(templ_dir_path, 'script_template.py')) FreeCAD.Console.PrintMessage("Please save this template file as another name before creating any others.\r\n")
def Activated(self): #We need to close any file that's already open in the editor window CadQueryCloseScript().Activated() module_base_path = module_locator.module_path() templ_dir_path = os.path.join(module_base_path, 'Templates') #Use the library that FreeCAD can use as well to open CQ files ImportCQ.open(os.path.join(templ_dir_path, 'script_template.py'))
def Activated(self): FreeCAD.Console.PrintMessage(self.exFile + "\r\n") # So we can open the "Open File" dialog mw = FreeCADGui.getMainWindow() # Start off defaulting to the Examples directory module_base_path = module_locator.module_path() exs_dir_path = os.path.join(module_base_path, 'Libs/cadquery/examples/FreeCAD') # Append this script's directory to sys.path sys.path.append(os.path.dirname(exs_dir_path)) # We've created a library that FreeCAD can use as well to open CQ files ImportCQ.open(os.path.join(exs_dir_path, self.exFile))
def Activated(self): mw = FreeCADGui.getMainWindow() #Try to keep track of the previous path used to open as a convenience to the user if self.previousPath is None: self.previousPath = "/home/" filename = QtGui.QFileDialog.getOpenFileName(mw, mw.tr("Open CadQuery Script"), self.previousPath, mw.tr("CadQuery Files (*.py)")) self.previousPath = filename[0] #Make sure the user didn't click cancel if filename[0]: #We've created a library that FreeCAD can use as well to open CQ files ImportCQ.open(filename[0])
def Activated(self): # So we can open the "Open File" dialog mw = FreeCADGui.getMainWindow() # Try to keep track of the previous path used to open as a convenience to the user if self.previousPath is None: # Start off defaulting to the Examples directory module_base_path = module_locator.module_path() exs_dir_path = os.path.join(module_base_path, "Examples") self.previousPath = exs_dir_path filename = QtGui.QFileDialog.getOpenFileName( mw, mw.tr("Open CadQuery Script"), self.previousPath, mw.tr("CadQuery Files (*.py)") ) # Make sure the user didn't click cancel if filename[0]: # We need to close any file that's already open in the editor window CadQueryCloseScript().Activated() self.previousPath = filename[0] # Append this script's directory to sys.path sys.path.append(os.path.dirname(filename[0])) # We've created a library that FreeCAD can use as well to open CQ files ImportCQ.open(filename[0]) docname = os.path.splitext(os.path.basename(filename[0]))[0] FreeCAD.newDocument(docname) # Execute the script CadQueryExecuteScript().Activated() # Get a nice view of our model FreeCADGui.activeDocument().activeView().viewAxometric() FreeCADGui.SendMsgToActiveView("ViewFit")
def Activated(self): #So we can open the "Open File" dialog mw = FreeCADGui.getMainWindow() #Try to keep track of the previous path used to open as a convenience to the user if self.previousPath is None: #Start off defaulting to the Examples directory module_base_path = module_locator.module_path() exs_dir_path = os.path.join(module_base_path, 'Examples') self.previousPath = exs_dir_path filename = QtGui.QFileDialog.getOpenFileName( mw, mw.tr("Open CadQuery Script"), self.previousPath, mw.tr("CadQuery Files (*.py)")) #Make sure the user didn't click cancel if filename[0]: #We need to close any file that's already open in the editor window CadQueryCloseScript().Activated() self.previousPath = filename[0] #Append this script's directory to sys.path sys.path.append(os.path.dirname(filename[0])) #We've created a library that FreeCAD can use as well to open CQ files ImportCQ.open(filename[0]) docname = os.path.splitext(os.path.basename(filename[0]))[0] FreeCAD.newDocument(docname) #Execute the script CadQueryExecuteScript().Activated() #Get a nice view of our model FreeCADGui.activeDocument().activeView().viewAxometric() FreeCADGui.SendMsgToActiveView("ViewFit")
def Activated(self): # So we can open the "Open File" dialog mw = FreeCADGui.getMainWindow() # Try to keep track of the previous path used to open as a convenience to the user if self.previousPath is None: # Start off defaulting to the Examples directory module_base_path = module_locator.module_path() exs_dir_path = os.path.join(module_base_path, 'Libs/cadquery/examples/FreeCAD') self.previousPath = exs_dir_path filename = QtGui.QFileDialog.getOpenFileName(mw, mw.tr("Open CadQuery Script"), self.previousPath, mw.tr("CadQuery Files (*.py)")) # Make sure the user didn't click cancel if filename[0]: self.previousPath = filename[0] # Append this script's directory to sys.path sys.path.append(os.path.dirname(filename[0])) # We've created a library that FreeCAD can use as well to open CQ files ImportCQ.open(filename[0])
def Activated(self): module_base_path = module_locator.module_path() templ_dir_path = os.path.join(module_base_path, 'Templates') # Use the library that FreeCAD can use as well to open CQ files ImportCQ.open(os.path.join(templ_dir_path, 'script_template.py'))