Arch: Adapted all other tools to doCommand() + translatable

This commit is contained in:
Yorik van Havre
2012-05-31 12:30:20 -03:00
parent 539cad092a
commit 2a3ff10d84
9 changed files with 173 additions and 86 deletions

View File

@@ -24,12 +24,13 @@
import FreeCAD,FreeCADGui,Draft,ArchComponent,DraftVecUtils
from FreeCAD import Vector
from PyQt4 import QtCore
from DraftTools import translate
__title__="FreeCAD Structure"
__author__ = "Yorik van Havre"
__url__ = "http://free-cad.sourceforge.net"
def makeStructure(baseobj=None,length=None,width=None,height=None,name="Structure"):
def makeStructure(baseobj=None,length=None,width=None,height=None,name=str(translate("Arch","Structure"))):
'''makeStructure([obj],[length],[width],[heigth],[swap]): creates a
structure element based on the given profile object and the given
extrusion height. If no base object is given, you can also specify
@@ -64,29 +65,31 @@ class _CommandStructure:
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Structure","Creates a structure object from scratch or from a selected object (sketch, wire, face or solid)")}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Structure")))
FreeCADGui.doCommand("import Arch")
sel = FreeCADGui.Selection.getSelection()
if sel:
FreeCAD.ActiveDocument.openTransaction("Structure")
for obj in sel:
makeStructure(obj)
FreeCAD.ActiveDocument.commitTransaction()
FreeCADGui.doCommand("Arch.makeStructure(FreeCAD.ActiveDocument."+obj.Name+")")
else:
makeStructure()
FreeCADGui.doCommand("Arch.makeStructure()")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _Structure(ArchComponent.Component):
"The Structure object"
def __init__(self,obj):
ArchComponent.Component.__init__(self,obj)
obj.addProperty("App::PropertyLength","Length","Base",
"The length of this element, if not based on a profile")
str(translate("Arch","The length of this element, if not based on a profile")))
obj.addProperty("App::PropertyLength","Width","Base",
"The width of this element, if not based on a profile")
str(translate("Arch","The width of this element, if not based on a profile")))
obj.addProperty("App::PropertyLength","Height","Base",
"The height or extrusion depth of this element. Keep 0 for automatic")
str(translate("Arch","The height or extrusion depth of this element. Keep 0 for automatic")))
obj.addProperty("App::PropertyLinkList","Axes","Base",
"Axes systems this structure is built on")
str(translate("Arch","Axes systems this structure is built on")))
obj.addProperty("App::PropertyVector","Normal","Base",
"The normal extrusion direction of this object (keep (0,0,0) for automatic normal)")
str(translate("Arch","The normal extrusion direction of this object (keep (0,0,0) for automatic normal)")))
self.Type = "Structure"
def execute(self,obj):
@@ -167,7 +170,6 @@ class _Structure(ArchComponent.Component):
if hasattr(hole,"Proxy"):
if hasattr(hole.Proxy,"Subvolume"):
if hole.Proxy.Subvolume:
print "cutting subvolume",hole.Proxy.Subvolume
base = base.cut(hole.Proxy.Subvolume)
cut = True
if not cut: