0001151: Draft loads Part module at start

+ Fixed loading of Part module at startup
+ Minor cleaning around
This commit is contained in:
Yorik van Havre 2013-06-15 15:39:29 -03:00
parent 6a9594d4c0
commit 31fbfd33ef
6 changed files with 50 additions and 37 deletions

View File

@ -59,13 +59,14 @@ class ArchWorkbench(Workbench):
" *@!!!!!$=* ",
" =>!!$& ",
" -+ ",
" "};"""
" "};"""
MenuText = "Arch"
ToolTip = "Architecture workbench"
def Initialize(self):
import DraftTools,DraftGui,Arch_rc,Arch,Draft_rc
from DraftTools import translate
# arch tools
self.archtools = ["Arch_Wall","Arch_Structure",
@ -91,23 +92,24 @@ class ArchWorkbench(Workbench):
"Draft_ShowSnapBar","Draft_ToggleGrid","Draft_UndoLine",
"Draft_FinishLine","Draft_CloseLine"]
self.appendToolbar(str(DraftTools.translate("arch","Arch tools")),self.archtools)
self.appendToolbar(str(DraftTools.translate("arch","Draft tools")),self.drafttools)
self.appendToolbar(str(DraftTools.translate("arch","Draft mod tools")),self.draftmodtools)
self.appendMenu([str(DraftTools.translate("arch","&Architecture")),str(DraftTools.translate("arch","Conversion Tools"))],self.meshtools)
self.appendMenu([str(DraftTools.translate("arch","&Architecture")),str(DraftTools.translate("arch","Calculation Tools"))],self.calctools)
self.appendMenu(str(DraftTools.translate("arch","&Architecture")),self.archtools)
self.appendMenu(str(DraftTools.translate("arch","&Draft")),self.drafttools+self.draftmodtools)
self.appendMenu([str(DraftTools.translate("arch","&Draft")),str(DraftTools.translate("arch","Context Tools"))],self.draftcontexttools)
self.appendToolbar(str(translate("arch","Arch tools")),self.archtools)
self.appendToolbar(str(translate("arch","Draft tools")),self.drafttools)
self.appendToolbar(str(translate("arch","Draft mod tools")),self.draftmodtools)
self.appendMenu([str(translate("arch","&Architecture")),str(translate("arch","Conversion Tools"))],self.meshtools)
self.appendMenu([str(translate("arch","&Architecture")),str(translate("arch","Calculation Tools"))],self.calctools)
self.appendMenu(str(translate("arch","&Architecture")),self.archtools)
self.appendMenu(str(translate("arch","&Draft")),self.drafttools+self.draftmodtools)
self.appendMenu([str(translate("arch","&Draft")),str(translate("arch","Context Tools"))],self.draftcontexttools)
FreeCADGui.addIconPath(":/icons")
FreeCADGui.addLanguagePath(":/translations")
FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
FreeCADGui.draftToolBar.loadedPreferences = True
if hasattr(FreeCADGui,"draftToolBar"):
if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
FreeCADGui.draftToolBar.loadedPreferences = True
Log ('Loading Arch module... done\n')
def Activated(self):
if hasattr(FreeCADGui,"draftToolBar"):
FreeCADGui.draftToolBar.Activated()
@ -121,7 +123,7 @@ class ArchWorkbench(Workbench):
if hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper.hide()
Msg("Arch workbench deactivated\n")
def ContextMenu(self, recipient):
self.appendContextMenu("Draft context tools",self.draftcontexttools)
@ -129,9 +131,12 @@ class ArchWorkbench(Workbench):
return "Gui::PythonWorkbench"
FreeCADGui.addWorkbench(ArchWorkbench)
# add import/export types
FreeCAD.addImportType("Industry Foundation Classes (*.ifc)","importIFC")
FreeCAD.addExportType("Wavefront OBJ - Arch module (*.obj)","importOBJ")
FreeCAD.addExportType("WebGL file (*.html)","importWebGL")
# check for pycollada
try:
import collada

View File

@ -33,7 +33,7 @@ Report to Draft.py for info
import FreeCAD, FreeCADGui, os, Draft, sys
try:
from PyQt4 import QtCore,QtGui,QtSvg
from PyQt4 import QtCore,QtGui,QtSvg
except:
FreeCAD.Console.PrintMessage("Error: Python-qt4 package must be installed on your system to use the Draft module.")

View File

@ -27,7 +27,6 @@ __url__ = "http://free-cad.sourceforge.net"
import FreeCAD, FreeCADGui, math, Draft, DraftGui, DraftTrackers, DraftVecUtils
from DraftGui import todo,getMainWindow
from FreeCAD import Vector
from pivy import coin
from PyQt4 import QtCore,QtGui
@ -118,7 +117,7 @@ class Snapper:
if not hasattr(self,"toolbar"):
self.makeSnapToolBar()
mw = getMainWindow()
mw = DraftGui.getMainWindow()
bt = mw.findChild(QtGui.QToolBar,"Draft Snap")
if not bt:
mw.addToolBar(self.toolbar)
@ -929,7 +928,7 @@ class Snapper:
"shows the toolbar and the grid"
if not hasattr(self,"toolbar"):
self.makeSnapToolBar()
mw = getMainWindow()
mw = DraftGui.getMainWindow()
bt = mw.findChild(QtGui.QToolBar,"Draft Snap")
if not bt:
mw.addToolBar(self.toolbar)

View File

@ -28,7 +28,6 @@ __url__ = "http://free-cad.sourceforge.net"
import FreeCAD,FreeCADGui,math,Draft, DraftVecUtils
from FreeCAD import Vector
from pivy import coin
from DraftGui import todo
class Tracker:
"A generic Draft Tracker, to be used by other specific trackers"
@ -52,9 +51,11 @@ class Tracker:
self.switch.addChild(node)
self.switch.whichChild = -1
self.Visible = False
from DraftGui import todo
todo.delay(self._insertSwitch, self.switch)
def finalize(self):
from DraftGui import todo
todo.delay(self._removeSwitch, self.switch)
self.switch = None

View File

@ -62,8 +62,8 @@ class DraftWorkbench (Workbench):
".&&.++***,,)))!!",
"#==+)!!!!!!!!!!!",
" ##+)!!!!!!!!!!!",
" *,,,,,,,,,,,,"};"""
" *,,,,,,,,,,,,"};"""
MenuText = "Draft"
ToolTip = "The Draft module is used for basic 2D CAD Drafting"
@ -92,19 +92,18 @@ class DraftWorkbench (Workbench):
depsOK = True
if not depsOK:
return
# import Draft tools, icons and macros menu
try:
import os,macros,DraftTools,DraftGui,Draft_rc
import os,macros,Draft_rc,DraftTools, DraftGui
from DraftTools import translate
FreeCADGui.addLanguagePath(":/translations")
FreeCADGui.addIconPath(":/icons")
if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
FreeCADGui.draftToolBar.loadedPreferences = True
self.appendMenu(["&Macro",str(DraftTools.translate("draft","Installed Macros"))],macros.macrosList)
Log ('Loading Draft module...done\n')
self.appendMenu(["&Macro",str(translate("draft","Installed Macros"))],macros.macrosList)
except:
pass
# setup menus
self.cmdList = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",
"Draft_Polygon","Draft_Rectangle", "Draft_Text",
"Draft_Dimension", "Draft_BSpline","Draft_Point",
@ -120,10 +119,16 @@ class DraftWorkbench (Workbench):
self.lineList = ["Draft_UndoLine","Draft_FinishLine","Draft_CloseLine"]
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench","Draft creation tools"),self.cmdList)
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench","Draft modification tools"),self.modList)
self.appendMenu(str(DraftTools.translate("draft","&Draft")),self.cmdList+self.modList)
self.appendMenu([str(DraftTools.translate("draft","&Draft")),str(DraftTools.translate("draft","Context tools"))],self.treecmdList)
self.appendMenu([str(DraftTools.translate("draft","&Draft")),str(DraftTools.translate("draft","Wire tools"))],self.lineList)
self.appendMenu(str(translate("draft","&Draft")),self.cmdList+self.modList)
self.appendMenu([str(translate("draft","&Draft")),str(translate("draft","Context tools"))],self.treecmdList)
self.appendMenu([str(translate("draft","&Draft")),str(translate("draft","Wire tools"))],self.lineList)
if hasattr(FreeCADGui,"draftToolBar"):
if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
FreeCADGui.draftToolBar.loadedPreferences = True
Log ('Loading Draft module...done\n')
def Activated(self):
if hasattr(FreeCADGui,"draftToolBar"):
FreeCADGui.draftToolBar.Activated()
@ -159,6 +164,8 @@ class DraftWorkbench (Workbench):
# ability to turn off the Draft workbench (since it is also all included in Arch)
if not FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetBool("hideDraftWorkbench"):
FreeCADGui.addWorkbench(DraftWorkbench)
# add Import/Export types
App.addImportType("Autodesk DXF (*.dxf)","importDXF")
App.addImportType("SVG as geometry (*.svg)","importSVG")
App.addImportType("Open CAD Format (*.oca *.gcad)","importOCA")
@ -167,7 +174,7 @@ App.addExportType("Autodesk DXF (*.dxf)","importDXF")
App.addExportType("Flattened SVG (*.svg)","importSVG")
App.addExportType("Open CAD Format (*.oca)","importOCA")
# DWG support
# add DWG support
import importDWG
if importDWG.getTeighaConverter():
App.addImportType("Autodesk DWG (*.dwg)","importDWG")

View File

@ -38,7 +38,7 @@ currently unsupported: use, image
# implement inherting fill style from group
# handle relative units
import xml.sax, string, FreeCAD, os, math, re, Draft, DraftVecUtils, DraftGeomUtils
import xml.sax, string, FreeCAD, os, math, re, Draft, DraftVecUtils
from FreeCAD import Vector
try: import FreeCADGui
@ -283,6 +283,7 @@ def makewire(path,checkclosed=False,donttry=False):
#ToDo Do not catch all exceptions
if not donttry:
try:
import DraftGeomUtils
sh = Part.Wire(DraftGeomUtils.sortEdges(path))
#sh = Part.Wire(path)
isok = (not checkclosed) or sh.isClosed()