Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code

This commit is contained in:
wmayer 2015-01-05 16:29:06 +01:00
commit 71efef4761
16 changed files with 332 additions and 320 deletions

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -36,10 +36,11 @@ __title__="FreeCAD Axis System"
__author__ = "Yorik van Havre" __author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org" __url__ = "http://www.freecadweb.org"
def makeAxis(num=5,size=1000,name=translate("Arch","Axes")): def makeAxis(num=5,size=1000,name="Axes"):
'''makeAxis(num,size): makes an Axis System '''makeAxis(num,size): makes an Axis System
based on the given number of axes and interval distances''' based on the given number of axes and interval distances'''
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
obj.Label = translate("Arch",name)
_Axis(obj) _Axis(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderAxis(obj.ViewObject) _ViewProviderAxis(obj.ViewObject)
@ -61,7 +62,7 @@ class _CommandAxis:
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Axis","Axis"), 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Axis","Axis"),
'Accel': "A, X", 'Accel': "A, X",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Axis","Creates an axis system.")} 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Axis","Creates an axis system.")}
def Activated(self): def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Axis")) FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Axis"))
FreeCADGui.addModule("Arch") FreeCADGui.addModule("Arch")
@ -76,7 +77,7 @@ class _CommandAxis:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
class _Axis: class _Axis:
"The Axis object" "The Axis object"
def __init__(self,obj): def __init__(self,obj):
@ -88,7 +89,7 @@ class _Axis:
self.Type = "Axis" self.Type = "Axis"
obj.Length=3000 obj.Length=3000
obj.Proxy = self obj.Proxy = self
def execute(self,obj): def execute(self,obj):
import Part import Part
geoms = [] geoms = []
@ -109,7 +110,7 @@ class _Axis:
sh = Part.Compound(geoms) sh = Part.Compound(geoms)
sh.Placement = obj.Placement sh.Placement = obj.Placement
obj.Shape = sh obj.Shape = sh
def onChanged(self,obj,prop): def onChanged(self,obj,prop):
if prop in ["Angles","Distances","Placement"]: if prop in ["Angles","Distances","Placement"]:
self.execute(obj) self.execute(obj)
@ -120,7 +121,7 @@ class _Axis:
def __setstate__(self,state): def __setstate__(self,state):
if state: if state:
self.Type = state self.Type = state
class _ViewProviderAxis: class _ViewProviderAxis:
"A View Provider for the Axis object" "A View Provider for the Axis object"
@ -138,7 +139,7 @@ class _ViewProviderAxis:
vobj.LineColor = (0.13,0.15,0.37) vobj.LineColor = (0.13,0.15,0.37)
vobj.DrawStyle = "Dashdot" vobj.DrawStyle = "Dashdot"
vobj.NumberingStyle = "1,2,3" vobj.NumberingStyle = "1,2,3"
def getIcon(self): def getIcon(self):
import Arch_rc import Arch_rc
return ":/icons/Arch_Axis_Tree.svg" return ":/icons/Arch_Axis_Tree.svg"
@ -162,7 +163,7 @@ class _ViewProviderAxis:
sep.addChild(self.bubbleset) sep.addChild(self.bubbleset)
vobj.addDisplayMode(sep,"Default") vobj.addDisplayMode(sep,"Default")
self.onChanged(vobj,"BubbleSize") self.onChanged(vobj,"BubbleSize")
def getDisplayModes(self,vobj): def getDisplayModes(self,vobj):
return ["Default"] return ["Default"]
@ -309,15 +310,15 @@ class _ViewProviderAxis:
elif vobj.NumberingStyle == "L0,L1,L2": elif vobj.NumberingStyle == "L0,L1,L2":
t.string = "L"+str(num) t.string = "L"+str(num)
num += 1 num += 1
def setEdit(self,vobj,mode=0): def setEdit(self,vobj,mode=0):
taskd = _AxisTaskPanel() taskd = _AxisTaskPanel()
taskd.obj = vobj.Object taskd.obj = vobj.Object
taskd.update() taskd.update()
FreeCADGui.Control.showDialog(taskd) FreeCADGui.Control.showDialog(taskd)
return True return True
def unsetEdit(self,vobj,mode): def unsetEdit(self,vobj,mode):
FreeCADGui.Control.closeDialog() FreeCADGui.Control.closeDialog()
return return
@ -338,9 +339,9 @@ class _AxisTaskPanel:
# the panel has a tree widget that contains categories # the panel has a tree widget that contains categories
# for the subcomponents, such as additions, subtractions. # for the subcomponents, such as additions, subtractions.
# the categories are shown only if they are not empty. # the categories are shown only if they are not empty.
self.updating = False self.updating = False
self.obj = None self.obj = None
self.form = QtGui.QWidget() self.form = QtGui.QWidget()
self.form.setObjectName("TaskPanel") self.form.setObjectName("TaskPanel")
@ -356,8 +357,8 @@ class _AxisTaskPanel:
self.tree.header().resizeSection(0,50) self.tree.header().resizeSection(0,50)
self.tree.header().resizeSection(1,80) self.tree.header().resizeSection(1,80)
self.tree.header().resizeSection(2,60) self.tree.header().resizeSection(2,60)
# buttons # buttons
self.addButton = QtGui.QPushButton(self.form) self.addButton = QtGui.QPushButton(self.form)
self.addButton.setObjectName("addButton") self.addButton.setObjectName("addButton")
self.addButton.setIcon(QtGui.QIcon(":/icons/Arch_Add.svg")) self.addButton.setIcon(QtGui.QIcon(":/icons/Arch_Add.svg"))
@ -383,7 +384,7 @@ class _AxisTaskPanel:
def getStandardButtons(self): def getStandardButtons(self):
return int(QtGui.QDialogButtonBox.Close) return int(QtGui.QDialogButtonBox.Close)
def update(self): def update(self):
'fills the treewidget' 'fills the treewidget'
self.updating = True self.updating = True
@ -398,7 +399,7 @@ class _AxisTaskPanel:
item.setTextAlignment(0,QtCore.Qt.AlignLeft) item.setTextAlignment(0,QtCore.Qt.AlignLeft)
self.retranslateUi(self.form) self.retranslateUi(self.form)
self.updating = False self.updating = False
def addElement(self): def addElement(self):
item = QtGui.QTreeWidgetItem(self.tree) item = QtGui.QTreeWidgetItem(self.tree)
item.setText(0,str(self.tree.topLevelItemCount())) item.setText(0,str(self.tree.topLevelItemCount()))
@ -413,7 +414,7 @@ class _AxisTaskPanel:
nr = int(it.text(0))-1 nr = int(it.text(0))-1
self.resetObject(remove=nr) self.resetObject(remove=nr)
self.update() self.update()
def edit(self,item,column): def edit(self,item,column):
if not self.updating: if not self.updating:
self.resetObject() self.resetObject()
@ -431,12 +432,12 @@ class _AxisTaskPanel:
self.obj.Angles = a self.obj.Angles = a
self.obj.touch() self.obj.touch()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
def reject(self): def reject(self):
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.ActiveDocument.resetEdit()
return True return True
def retranslateUi(self, TaskPanel): def retranslateUi(self, TaskPanel):
TaskPanel.setWindowTitle(QtGui.QApplication.translate("Arch", "Axes", None, QtGui.QApplication.UnicodeUTF8)) TaskPanel.setWindowTitle(QtGui.QApplication.translate("Arch", "Axes", None, QtGui.QApplication.UnicodeUTF8))
self.delButton.setText(QtGui.QApplication.translate("Arch", "Remove", None, QtGui.QApplication.UnicodeUTF8)) self.delButton.setText(QtGui.QApplication.translate("Arch", "Remove", None, QtGui.QApplication.UnicodeUTF8))
@ -445,6 +446,6 @@ class _AxisTaskPanel:
self.tree.setHeaderLabels([QtGui.QApplication.translate("Arch", "Axis", None, QtGui.QApplication.UnicodeUTF8), self.tree.setHeaderLabels([QtGui.QApplication.translate("Arch", "Axis", None, QtGui.QApplication.UnicodeUTF8),
QtGui.QApplication.translate("Arch", "Distance", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("Arch", "Distance", None, QtGui.QApplication.UnicodeUTF8),
QtGui.QApplication.translate("Arch", "Angle", None, QtGui.QApplication.UnicodeUTF8)]) QtGui.QApplication.translate("Arch", "Angle", None, QtGui.QApplication.UnicodeUTF8)])
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Axis',_CommandAxis()) FreeCADGui.addCommand('Arch_Axis',_CommandAxis())

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -34,7 +34,7 @@ __title__="FreeCAD Building"
__author__ = "Yorik van Havre" __author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org" __url__ = "http://www.freecadweb.org"
def makeBuilding(objectslist=None,baseobj=None,name=translate("Arch","Building")): def makeBuilding(objectslist=None,baseobj=None,name="Building"):
'''makeBuilding(objectslist): creates a building including the '''makeBuilding(objectslist): creates a building including the
objects from the given list.''' objects from the given list.'''
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name) obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
@ -43,6 +43,7 @@ def makeBuilding(objectslist=None,baseobj=None,name=translate("Arch","Building")
_ViewProviderBuilding(obj.ViewObject) _ViewProviderBuilding(obj.ViewObject)
if objectslist: if objectslist:
obj.Group = objectslist obj.Group = objectslist
obj.Label = translate("Arch",name)
return obj return obj
class _CommandBuilding: class _CommandBuilding:
@ -55,7 +56,7 @@ class _CommandBuilding:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
def Activated(self): def Activated(self):
sel = FreeCADGui.Selection.getSelection() sel = FreeCADGui.Selection.getSelection()
ok = False ok = False
@ -81,18 +82,18 @@ class _CommandBuilding:
FreeCADGui.doCommand("Arch.makeBuilding("+ss+")") FreeCADGui.doCommand("Arch.makeBuilding("+ss+")")
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
class _Building(ArchFloor._Floor): class _Building(ArchFloor._Floor):
"The Building object" "The Building object"
def __init__(self,obj): def __init__(self,obj):
ArchFloor._Floor.__init__(self,obj) ArchFloor._Floor.__init__(self,obj)
self.Type = "Building" self.Type = "Building"
obj.setEditorMode('Height',2) obj.setEditorMode('Height',2)
class _ViewProviderBuilding(ArchFloor._ViewProviderFloor): class _ViewProviderBuilding(ArchFloor._ViewProviderFloor):
"A View Provider for the Building object" "A View Provider for the Building object"
def __init__(self,vobj): def __init__(self,vobj):
ArchFloor._ViewProviderFloor.__init__(self,vobj) ArchFloor._ViewProviderFloor.__init__(self,vobj)
def getIcon(self): def getIcon(self):
import Arch_rc import Arch_rc

View File

@ -2,8 +2,8 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2014 * #* Copyright (c) 2014 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -41,7 +41,7 @@ else:
Roles = ["Furniture", "Hydro Equipment", "Electric Equipment"] Roles = ["Furniture", "Hydro Equipment", "Electric Equipment"]
def makeEquipment(baseobj=None,placement=None,name=translate("Arch","Equipment"),type=None): def makeEquipment(baseobj=None,placement=None,name="Equipment",type=None):
"makeEquipment([baseobj,placement,name,type]): creates an equipment object from the given base object" "makeEquipment([baseobj,placement,name,type]): creates an equipment object from the given base object"
if type: if type:
if type == "Part": if type == "Part":
@ -62,7 +62,7 @@ def makeEquipment(baseobj=None,placement=None,name=translate("Arch","Equipment")
else: else:
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
_Equipment(obj) _Equipment(obj)
obj.Label = name obj.Label = translate("Arch",name)
if placement: if placement:
obj.Placement = placement obj.Placement = placement
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
@ -76,12 +76,12 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
projection of the given mesh object in the given direction (default = on the XY plane). If projection of the given mesh object in the given direction (default = on the XY plane). If
outeronly is True, only the outer contour is taken into consideration, discarding the inner outeronly is True, only the outer contour is taken into consideration, discarding the inner
holes. If largestonly is True, only the largest segment of the given mesh will be used.""" holes. If largestonly is True, only the largest segment of the given mesh will be used."""
import Mesh, math, Part, DraftGeomUtils import Mesh, math, Part, DraftGeomUtils
if not obj.isDerivedFrom("Mesh::Feature"): if not obj.isDerivedFrom("Mesh::Feature"):
return return
mesh = obj.Mesh mesh = obj.Mesh
# 1. Flattening the mesh # 1. Flattening the mesh
proj = [] proj = []
for f in mesh.Facets: for f in mesh.Facets:
@ -95,16 +95,16 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
nf.append(p) nf.append(p)
proj.append(nf) proj.append(nf)
flatmesh = Mesh.Mesh(proj) flatmesh = Mesh.Mesh(proj)
# 2. Removing wrong faces # 2. Removing wrong faces
facets = [] facets = []
for f in flatmesh.Facets: for f in flatmesh.Facets:
if f.Normal.getAngle(direction) < math.pi: if f.Normal.getAngle(direction) < math.pi:
facets.append(f) facets.append(f)
cleanmesh = Mesh.Mesh(facets) cleanmesh = Mesh.Mesh(facets)
#Mesh.show(cleanmesh) #Mesh.show(cleanmesh)
# 3. Getting the bigger mesh from the planar segments # 3. Getting the bigger mesh from the planar segments
if largestonly: if largestonly:
c = cleanmesh.getSeparateComponents() c = cleanmesh.getSeparateComponents()
@ -122,9 +122,9 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
a = m.Area a = m.Area
#Mesh.show(boundarymesh) #Mesh.show(boundarymesh)
cleanmesh = boundarymesh cleanmesh = boundarymesh
# 4. Creating a Part and getting the contour # 4. Creating a Part and getting the contour
shape = None shape = None
for f in cleanmesh.Facets: for f in cleanmesh.Facets:
p = Part.makePolygon(f.Points+[f.Points[0]]) p = Part.makePolygon(f.Points+[f.Points[0]])
@ -140,7 +140,7 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
shape = shape.removeSplitter() shape = shape.removeSplitter()
# 5. Extracting the largest wire # 5. Extracting the largest wire
if outeronly: if outeronly:
count = 0 count = 0
largest = None largest = None
@ -155,10 +155,10 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
print "Unable to produce a face from the outer wire." print "Unable to produce a face from the outer wire."
else: else:
shape = f shape = f
return shape return shape
class _CommandEquipment: class _CommandEquipment:
"the Arch Equipment command definition" "the Arch Equipment command definition"
def GetResources(self): def GetResources(self):
@ -169,8 +169,8 @@ class _CommandEquipment:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
def Activated(self): def Activated(self):
s = FreeCADGui.Selection.getSelection() s = FreeCADGui.Selection.getSelection()
if not s: if not s:
FreeCAD.Console.PrintError(translate("Arch","You must select a base object first!")) FreeCAD.Console.PrintError(translate("Arch","You must select a base object first!"))
@ -185,8 +185,8 @@ class _CommandEquipment:
if hasattr(s[0].ViewObject,"DiffuseColor"): if hasattr(s[0].ViewObject,"DiffuseColor"):
FreeCADGui.doCommand("FreeCAD.ActiveDocument.Objects[-1].ViewObject.DiffuseColor = FreeCAD.ActiveDocument." + base + ".ViewObject.DiffuseColor") FreeCADGui.doCommand("FreeCAD.ActiveDocument.Objects[-1].ViewObject.DiffuseColor = FreeCAD.ActiveDocument." + base + ".ViewObject.DiffuseColor")
return return
class _Command3Views: class _Command3Views:
"the Arch 3Views command definition" "the Arch 3Views command definition"
def GetResources(self): def GetResources(self):
@ -196,8 +196,8 @@ class _Command3Views:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
def Activated(self): def Activated(self):
s = FreeCADGui.Selection.getSelection() s = FreeCADGui.Selection.getSelection()
if len(s) != 1: if len(s) != 1:
FreeCAD.Console.PrintError(translate("Arch","You must select exactly one base object")) FreeCAD.Console.PrintError(translate("Arch","You must select exactly one base object"))
@ -243,10 +243,10 @@ class _Equipment(ArchComponent.Component):
self.Type = "Equipment" self.Type = "Equipment"
obj.Role = Roles obj.Role = Roles
obj.Proxy = self obj.Proxy = self
def onChanged(self,obj,prop): def onChanged(self,obj,prop):
self.hideSubobjects(obj,prop) self.hideSubobjects(obj,prop)
def execute(self,obj): def execute(self,obj):
pl = obj.Placement pl = obj.Placement
if obj.Base: if obj.Base:
@ -258,7 +258,7 @@ class _Equipment(ArchComponent.Component):
if base: if base:
import Mesh import Mesh
m = Mesh.Mesh(base.tessellate(1)) m = Mesh.Mesh(base.tessellate(1))
elif obj.Base.isDerivedFrom("Mesh::Feature"): elif obj.Base.isDerivedFrom("Mesh::Feature"):
m = obj.Base.Mesh.copy() m = obj.Base.Mesh.copy()
if m: if m:
@ -288,7 +288,7 @@ class _ViewProviderEquipment(ArchComponent.ViewProviderComponent):
def getIcon(self): def getIcon(self):
import Arch_rc import Arch_rc
return ":/icons/Arch_Equipment_Tree.svg" return ":/icons/Arch_Equipment_Tree.svg"
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Equipment',_CommandEquipment()) FreeCADGui.addCommand('Arch_Equipment',_CommandEquipment())

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -34,11 +34,11 @@ __title__="FreeCAD Arch Floor"
__author__ = "Yorik van Havre" __author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org" __url__ = "http://www.freecadweb.org"
def makeFloor(objectslist=None,baseobj=None,name=translate("Arch","Floor")): def makeFloor(objectslist=None,baseobj=None,name="Floor"):
'''makeFloor(objectslist): creates a floor including the '''makeFloor(objectslist): creates a floor including the
objects from the given list.''' objects from the given list.'''
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name) obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
obj.Label = name obj.Label = translate("Arch",name)
_Floor(obj) _Floor(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderFloor(obj.ViewObject) _ViewProviderFloor(obj.ViewObject)
@ -56,7 +56,7 @@ class _CommandFloor:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
def Activated(self): def Activated(self):
sel = FreeCADGui.Selection.getSelection() sel = FreeCADGui.Selection.getSelection()
ok = False ok = False
@ -81,7 +81,7 @@ class _CommandFloor:
FreeCADGui.doCommand("Arch.makeFloor("+ss+")") FreeCADGui.doCommand("Arch.makeFloor("+ss+")")
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
class _Floor: class _Floor:
"The Floor object" "The Floor object"
def __init__(self,obj): def __init__(self,obj):
@ -118,21 +118,21 @@ class _Floor:
if Draft.getType(o) in ["Wall","Structure"]: if Draft.getType(o) in ["Wall","Structure"]:
if not o.Height.Value: if not o.Height.Value:
o.Proxy.execute(o) o.Proxy.execute(o)
def addObject(self,child): def addObject(self,child):
if hasattr(self,"Object"): if hasattr(self,"Object"):
g = self.Object.Group g = self.Object.Group
if not child in g: if not child in g:
g.append(child) g.append(child)
self.Object.Group = g self.Object.Group = g
def removeObject(self,child): def removeObject(self,child):
if hasattr(self,"Object"): if hasattr(self,"Object"):
g = self.Object.Group g = self.Object.Group
if child in g: if child in g:
g.remove(child) g.remove(child)
self.Object.Group = g self.Object.Group = g
class _ViewProviderFloor: class _ViewProviderFloor:
"A View Provider for the Floor object" "A View Provider for the Floor object"
def __init__(self,vobj): def __init__(self,vobj):
@ -144,8 +144,8 @@ class _ViewProviderFloor:
def attach(self,vobj): def attach(self,vobj):
self.Object = vobj.Object self.Object = vobj.Object
return return
def claimChildren(self): def claimChildren(self):
return self.Object.Group return self.Object.Group
@ -155,5 +155,5 @@ class _ViewProviderFloor:
def __setstate__(self,state): def __setstate__(self,state):
return None return None
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Floor',_CommandFloor()) FreeCADGui.addCommand('Arch_Floor',_CommandFloor())

View File

@ -42,6 +42,7 @@ def makeFrame(baseobj,profile,name=translate("Arch","Frame")):
"""makeFrame(baseobj,profile,[name]): creates a frame object from a base sketch (or any other object """makeFrame(baseobj,profile,[name]): creates a frame object from a base sketch (or any other object
containing wires) and a profile object (an extrudable 2D object containing faces or closed wires)""" containing wires) and a profile object (an extrudable 2D object containing faces or closed wires)"""
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_Frame(obj) _Frame(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderFrame(obj.ViewObject) _ViewProviderFrame(obj.ViewObject)

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -43,12 +43,13 @@ Presets = [None,
["Plywoood 25mm, 1220 x 2440",1200,2400,18]] ["Plywoood 25mm, 1220 x 2440",1200,2400,18]]
def makePanel(baseobj=None,length=0,width=0,thickness=0,placement=None,name=translate("Arch","Panel")): def makePanel(baseobj=None,length=0,width=0,thickness=0,placement=None,name="Panel"):
'''makePanel([obj],[length],[width],[thickness],[placement]): creates a '''makePanel([obj],[length],[width],[thickness],[placement]): creates a
panel element based on the given profile object and the given panel element based on the given profile object and the given
extrusion thickness. If no base object is given, you can also specify extrusion thickness. If no base object is given, you can also specify
length and width for a simple cubic object.''' length and width for a simple cubic object.'''
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_Panel(obj) _Panel(obj)
_ViewProviderPanel(obj.ViewObject) _ViewProviderPanel(obj.ViewObject)
if baseobj: if baseobj:
@ -94,7 +95,7 @@ class _CommandPanel:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
def Activated(self): def Activated(self):
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
self.Length = p.GetFloat("PanelLength",1000) self.Length = p.GetFloat("PanelLength",1000)
self.Width = p.GetFloat("PanelWidth",1000) self.Width = p.GetFloat("PanelWidth",1000)
@ -128,7 +129,7 @@ class _CommandPanel:
self.tracker.length(self.Length) self.tracker.length(self.Length)
self.tracker.on() self.tracker.on()
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox()) FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox())
def getPoint(self,point=None,obj=None): def getPoint(self,point=None,obj=None):
"this function is called by the snapper when it has a 3D point" "this function is called by the snapper when it has a 3D point"
self.tracker.finalize() self.tracker.finalize()
@ -157,7 +158,7 @@ class _CommandPanel:
ui = FreeCADGui.UiLoader() ui = FreeCADGui.UiLoader()
w.setWindowTitle(translate("Arch","Panel options").decode("utf8")) w.setWindowTitle(translate("Arch","Panel options").decode("utf8"))
grid = QtGui.QGridLayout(w) grid = QtGui.QGridLayout(w)
# presets box # presets box
labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8")) labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8"))
valuep = QtGui.QComboBox() valuep = QtGui.QComboBox()
@ -167,14 +168,14 @@ class _CommandPanel:
valuep.addItems(fpresets) valuep.addItems(fpresets)
grid.addWidget(labelp,0,0,1,1) grid.addWidget(labelp,0,0,1,1)
grid.addWidget(valuep,0,1,1,1) grid.addWidget(valuep,0,1,1,1)
# length # length
label1 = QtGui.QLabel(translate("Arch","Length").decode("utf8")) label1 = QtGui.QLabel(translate("Arch","Length").decode("utf8"))
self.vLength = ui.createWidget("Gui::InputField") self.vLength = ui.createWidget("Gui::InputField")
self.vLength.setText(self.FORMAT % self.Length) self.vLength.setText(self.FORMAT % self.Length)
grid.addWidget(label1,1,0,1,1) grid.addWidget(label1,1,0,1,1)
grid.addWidget(self.vLength,1,1,1,1) grid.addWidget(self.vLength,1,1,1,1)
# width # width
label2 = QtGui.QLabel(translate("Arch","Width").decode("utf8")) label2 = QtGui.QLabel(translate("Arch","Width").decode("utf8"))
self.vWidth = ui.createWidget("Gui::InputField") self.vWidth = ui.createWidget("Gui::InputField")
@ -188,7 +189,7 @@ class _CommandPanel:
self.vHeight.setText(self.FORMAT % self.Thickness) self.vHeight.setText(self.FORMAT % self.Thickness)
grid.addWidget(label3,3,0,1,1) grid.addWidget(label3,3,0,1,1)
grid.addWidget(self.vHeight,3,1,1,1) grid.addWidget(self.vHeight,3,1,1,1)
# horizontal button # horizontal button
value5 = QtGui.QPushButton(translate("Arch","Rotate").decode("utf8")) value5 = QtGui.QPushButton(translate("Arch","Rotate").decode("utf8"))
grid.addWidget(value5,4,0,1,2) grid.addWidget(value5,4,0,1,2)
@ -212,7 +213,7 @@ class _CommandPanel:
QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue) QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
QtCore.QObject.connect(value5,QtCore.SIGNAL("pressed()"),self.rotate) QtCore.QObject.connect(value5,QtCore.SIGNAL("pressed()"),self.rotate)
return w return w
def update(self,point,info): def update(self,point,info):
"this function is called by the Snapper when the mouse is moved" "this function is called by the Snapper when the mouse is moved"
if FreeCADGui.Control.activeDialog(): if FreeCADGui.Control.activeDialog():
@ -225,7 +226,7 @@ class _CommandPanel:
self.tracker.width(self.Width) self.tracker.width(self.Width)
self.tracker.height(self.Thickness) self.tracker.height(self.Thickness)
self.tracker.length(self.Length) self.tracker.length(self.Length)
def setWidth(self,d): def setWidth(self,d):
self.Width = d self.Width = d
@ -239,13 +240,13 @@ class _CommandPanel:
self.continueCmd = bool(i) self.continueCmd = bool(i)
if hasattr(FreeCADGui,"draftToolBar"): if hasattr(FreeCADGui,"draftToolBar"):
FreeCADGui.draftToolBar.continueMode = bool(i) FreeCADGui.draftToolBar.continueMode = bool(i)
def setPreset(self,i): def setPreset(self,i):
if i > 0: if i > 0:
self.vLength.setText(self.FORMAT % float(Presets[i][1])) self.vLength.setText(self.FORMAT % float(Presets[i][1]))
self.vWidth.setText(self.FORMAT % float(Presets[i][2])) self.vWidth.setText(self.FORMAT % float(Presets[i][2]))
self.vHeight.setText(self.FORMAT % float(Presets[i][3])) self.vHeight.setText(self.FORMAT % float(Presets[i][3]))
def rotate(self): def rotate(self):
self.rotated = not self.rotated self.rotated = not self.rotated
@ -261,12 +262,12 @@ class _Panel(ArchComponent.Component):
obj.addProperty("App::PropertyLength","Offset","Arch",translate("Arch","The offset between this panel and its baseline")) obj.addProperty("App::PropertyLength","Offset","Arch",translate("Arch","The offset between this panel and its baseline"))
obj.Sheets = 1 obj.Sheets = 1
self.Type = "Panel" self.Type = "Panel"
def execute(self,obj): def execute(self,obj):
"creates the panel shape" "creates the panel shape"
import Part, DraftGeomUtils import Part, DraftGeomUtils
# base tests # base tests
if obj.Base: if obj.Base:
if obj.Base.isDerivedFrom("Part::Feature"): if obj.Base.isDerivedFrom("Part::Feature"):
@ -291,7 +292,7 @@ class _Panel(ArchComponent.Component):
return return
elif obj.Base.isDerivedFrom("Part::Feature"): elif obj.Base.isDerivedFrom("Part::Feature"):
if not obj.Base.Solids: if not obj.Base.Solids:
return return
# creating base shape # creating base shape
pl = obj.Placement pl = obj.Placement
@ -317,7 +318,7 @@ class _Panel(ArchComponent.Component):
base = ArchCommands.makeFace(base.Wires) base = ArchCommands.makeFace(base.Wires)
self.BaseProfile = base self.BaseProfile = base
self.ExtrusionVector = normal self.ExtrusionVector = normal
base = base.extrude(normal) base = base.extrude(normal)
elif obj.Base.isDerivedFrom("Mesh::Feature"): elif obj.Base.isDerivedFrom("Mesh::Feature"):
if obj.Base.Mesh.isSolid(): if obj.Base.Mesh.isSolid():
if obj.Base.Mesh.countComponents() == 1: if obj.Base.Mesh.countComponents() == 1:
@ -346,7 +347,7 @@ class _Panel(ArchComponent.Component):
b.translate(n) b.translate(n)
bases.append(b) bases.append(b)
base = Part.makeCompound(bases) base = Part.makeCompound(bases)
if base and normal and hasattr(obj,"Offset"): if base and normal and hasattr(obj,"Offset"):
if obj.Offset.Value: if obj.Offset.Value:
v = DraftVecUtils.scaleTo(normal,obj.Offset.Value) v = DraftVecUtils.scaleTo(normal,obj.Offset.Value)
@ -354,7 +355,7 @@ class _Panel(ArchComponent.Component):
# process subshapes # process subshapes
base = self.processSubShapes(obj,base,pl) base = self.processSubShapes(obj,base,pl)
# applying # applying
if base: if base:
if not base.isNull(): if not base.isNull():
@ -437,7 +438,7 @@ class _PanelView:
result += svg2 result += svg2
result += '</g>' result += '</g>'
obj.ViewResult = result obj.ViewResult = result
def onChanged(self, obj, prop): def onChanged(self, obj, prop):
pass pass

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2013 * #* Copyright (c) 2013 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -35,12 +35,13 @@ __title__="FreeCAD Rebar"
__author__ = "Yorik van Havre" __author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org" __url__ = "http://www.freecadweb.org"
def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name=translate("Arch","Rebar")): def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name="Rebar"):
"""makeRebar(baseobj,sketch,[diameter,amount,offset,name]): adds a Reinforcement Bar object """makeRebar(baseobj,sketch,[diameter,amount,offset,name]): adds a Reinforcement Bar object
to the given structural object, using the given sketch as profile.""" to the given structural object, using the given sketch as profile."""
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_Rebar(obj) _Rebar(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderRebar(obj.ViewObject) _ViewProviderRebar(obj.ViewObject)
@ -74,7 +75,7 @@ def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name=translate("
class _CommandRebar: class _CommandRebar:
"the Arch Rebar command definition" "the Arch Rebar command definition"
def GetResources(self): def GetResources(self):
return {'Pixmap' : 'Arch_Rebar', return {'Pixmap' : 'Arch_Rebar',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Rebar","Rebar"), 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Rebar","Rebar"),
@ -99,7 +100,7 @@ class _CommandRebar:
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
return return
else: else:
# we have only a base object: open the sketcher # we have only a base object: open the sketcher
FreeCADGui.activateWorkbench("SketcherWorkbench") FreeCADGui.activateWorkbench("SketcherWorkbench")
FreeCADGui.runCommand("Sketcher_NewSketch") FreeCADGui.runCommand("Sketcher_NewSketch")
@ -132,7 +133,7 @@ class _CommandRebar:
class _Rebar(ArchComponent.Component): class _Rebar(ArchComponent.Component):
"A parametric reinforcement bar (rebar) object" "A parametric reinforcement bar (rebar) object"
def __init__(self,obj): def __init__(self,obj):
ArchComponent.Component.__init__(self,obj) ArchComponent.Component.__init__(self,obj)
obj.addProperty("App::PropertyLength","Diameter","Arch","The diameter of the bar") obj.addProperty("App::PropertyLength","Diameter","Arch","The diameter of the bar")
@ -155,7 +156,7 @@ class _Rebar(ArchComponent.Component):
v = DraftGeomUtils.vec(e).normalize() v = DraftGeomUtils.vec(e).normalize()
return e.Vertexes[0].Point,v return e.Vertexes[0].Point,v
return None,None return None,None
def execute(self,obj): def execute(self,obj):
if len(obj.InList) != 1: if len(obj.InList) != 1:
return return
@ -237,7 +238,7 @@ class _Rebar(ArchComponent.Component):
obj.Shape = Part.makeCompound(shapes) obj.Shape = Part.makeCompound(shapes)
obj.Placement = pl obj.Placement = pl
class _ViewProviderRebar(ArchComponent.ViewProviderComponent): class _ViewProviderRebar(ArchComponent.ViewProviderComponent):
"A View Provider for the Rebar object" "A View Provider for the Rebar object"

View File

@ -35,12 +35,13 @@ __title__="FreeCAD Roof"
__author__ = "Yorik van Havre", "Jonathan Wiedemann" __author__ = "Yorik van Havre", "Jonathan Wiedemann"
__url__ = "http://www.freecadweb.org" __url__ = "http://www.freecadweb.org"
def makeRoof(baseobj=None,facenr=1, angles=[45.,], run = [], idrel = [0,],thickness = [1.,], overhang=[2.,], name=translate("Arch","Roof")): def makeRoof(baseobj=None,facenr=1, angles=[45.,], run = [], idrel = [0,],thickness = [1.,], overhang=[2.,], name="Roof"):
'''makeRoof(baseobj,[facenr],[angle],[name]) : Makes a roof based on a closed wire. '''makeRoof(baseobj,[facenr],[angle],[name]) : Makes a roof based on a closed wire.
face from an existing object. You can provide a list of angles, run, idrel, thickness, face from an existing object. You can provide a list of angles, run, idrel, thickness,
overhang for each edges in the wire to define the roof shape. The default for angle is 45 overhang for each edges in the wire to define the roof shape. The default for angle is 45
and the list is automatically complete to match with number of edges in the wire.''' and the list is automatically complete to match with number of edges in the wire.'''
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_Roof(obj) _Roof(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderRoof(obj.ViewObject) _ViewProviderRoof(obj.ViewObject)

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -32,10 +32,11 @@ else:
def translate(ctxt,txt): def translate(ctxt,txt):
return txt return txt
def makeSectionPlane(objectslist=None,name=translate("Arch","Section")): def makeSectionPlane(objectslist=None,name="Section"):
"""makeSectionPlane([objectslist]) : Creates a Section plane objects including the """makeSectionPlane([objectslist]) : Creates a Section plane objects including the
given objects. If no object is given, the whole document will be considered.""" given objects. If no object is given, the whole document will be considered."""
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
obj.Label = translate("Arch",name)
_SectionPlane(obj) _SectionPlane(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderSectionPlane(obj.ViewObject) _ViewProviderSectionPlane(obj.ViewObject)
@ -60,7 +61,7 @@ def makeSectionView(section,name="View"):
if not page: if not page:
page = FreeCAD.ActiveDocument.addObject("Drawing::FeaturePage",translate("Arch","Page")) page = FreeCAD.ActiveDocument.addObject("Drawing::FeaturePage",translate("Arch","Page"))
page.Template = Draft.getParam("template",FreeCAD.getResourceDir()+'Mod/Drawing/Templates/A3_Landscape.svg') page.Template = Draft.getParam("template",FreeCAD.getResourceDir()+'Mod/Drawing/Templates/A3_Landscape.svg')
view = FreeCAD.ActiveDocument.addObject("Drawing::FeatureViewPython",name) view = FreeCAD.ActiveDocument.addObject("Drawing::FeatureViewPython",name)
page.addObject(view) page.addObject(view)
_ArchDrawingView(view) _ArchDrawingView(view)
@ -104,7 +105,7 @@ class _SectionPlane:
obj.addProperty("App::PropertyBool","OnlySolids","Arch",translate("Arch","If false, non-solids will be cut too, with possible wrong results.")) obj.addProperty("App::PropertyBool","OnlySolids","Arch",translate("Arch","If false, non-solids will be cut too, with possible wrong results."))
obj.OnlySolids = True obj.OnlySolids = True
self.Type = "SectionPlane" self.Type = "SectionPlane"
def execute(self,obj): def execute(self,obj):
import Part import Part
if hasattr(obj.ViewObject,"DisplayLength"): if hasattr(obj.ViewObject,"DisplayLength"):
@ -126,7 +127,7 @@ class _SectionPlane:
def onChanged(self,obj,prop): def onChanged(self,obj,prop):
pass pass
def getNormal(self,obj): def getNormal(self,obj):
return obj.Shape.Faces[0].normalAt(0,0) return obj.Shape.Faces[0].normalAt(0,0)
@ -142,7 +143,7 @@ class _ViewProviderSectionPlane:
def __init__(self,vobj): def __init__(self,vobj):
vobj.addProperty("App::PropertyLength","DisplayLength","Arch",translate("Arch","The display length of this section plane")) vobj.addProperty("App::PropertyLength","DisplayLength","Arch",translate("Arch","The display length of this section plane"))
vobj.addProperty("App::PropertyLength","DisplayHeight","Arch",translate("Arch","The display height of this section plane")) vobj.addProperty("App::PropertyLength","DisplayHeight","Arch",translate("Arch","The display height of this section plane"))
vobj.addProperty("App::PropertyLength","ArrowSize","Arch",translate("Arch","The size of the arrows of this section plane")) vobj.addProperty("App::PropertyLength","ArrowSize","Arch",translate("Arch","The size of the arrows of this section plane"))
vobj.addProperty("App::PropertyPercent","Transparency","Base","") vobj.addProperty("App::PropertyPercent","Transparency","Base","")
vobj.addProperty("App::PropertyFloat","LineWidth","Base","") vobj.addProperty("App::PropertyFloat","LineWidth","Base","")
vobj.addProperty("App::PropertyColor","LineColor","Base","") vobj.addProperty("App::PropertyColor","LineColor","Base","")
@ -190,7 +191,7 @@ class _ViewProviderSectionPlane:
self.onChanged(vobj,"DisplayLength") self.onChanged(vobj,"DisplayLength")
self.onChanged(vobj,"LineColor") self.onChanged(vobj,"LineColor")
self.onChanged(vobj,"Transparency") self.onChanged(vobj,"Transparency")
def getDisplayModes(self,vobj): def getDisplayModes(self,vobj):
return ["Default"] return ["Default"]
@ -294,7 +295,7 @@ class _ArchDrawingView:
if hasattr(self,"spaces"): if hasattr(self,"spaces"):
if round(self.direction.getAngle(FreeCAD.Vector(0,0,1)),Draft.precision()) in [0,round(math.pi,Draft.precision())]: if round(self.direction.getAngle(FreeCAD.Vector(0,0,1)),Draft.precision()) in [0,round(math.pi,Draft.precision())]:
for s in self.spaces: for s in self.spaces:
svg += Draft.getSVG(s,scale=obj.Scale,fontsize=obj.FontSize.Value,direction=self.direction) svg += Draft.getSVG(s,scale=obj.Scale,fontsize=obj.FontSize.Value,direction=self.direction)
result = '' result = ''
result += '<g id="' + obj.Name + '"' result += '<g id="' + obj.Name + '"'
result += ' transform="' result += ' transform="'
@ -306,7 +307,7 @@ class _ArchDrawingView:
result += '</g>\n' result += '</g>\n'
# print "complete node:",result # print "complete node:",result
obj.ViewResult = result obj.ViewResult = result
def onChanged(self, obj, prop): def onChanged(self, obj, prop):
if prop in ["Source","RenderingMode","ShowCut"]: if prop in ["Source","RenderingMode","ShowCut"]:
import Part, DraftGeomUtils import Part, DraftGeomUtils
@ -325,10 +326,10 @@ class _ArchDrawingView:
os.append(o) os.append(o)
objs = os objs = os
self.svg = '' self.svg = ''
# generating SVG # generating SVG
if obj.RenderingMode == "Solid": if obj.RenderingMode == "Solid":
# render using the Arch Vector Renderer # render using the Arch Vector Renderer
import ArchVRM import ArchVRM
render = ArchVRM.Renderer() render = ArchVRM.Renderer()
render.setWorkingPlane(obj.Source.Placement) render.setWorkingPlane(obj.Source.Placement)
@ -343,7 +344,7 @@ class _ArchDrawingView:
if obj.ShowCut: if obj.ShowCut:
self.svg += render.getHiddenSVG(linewidth="LWPlaceholder") self.svg += render.getHiddenSVG(linewidth="LWPlaceholder")
# print render.info() # print render.info()
else: else:
# render using the Drawing module # render using the Drawing module
import Drawing, Part import Drawing, Part
@ -405,7 +406,7 @@ class _ArchDrawingView:
svgh = svgh.replace('stroke-width="0.35"','stroke-width="LWPlaceholder"') svgh = svgh.replace('stroke-width="0.35"','stroke-width="LWPlaceholder"')
svgh = svgh.replace('stroke-width="1"','stroke-width="LWPlaceholder"') svgh = svgh.replace('stroke-width="1"','stroke-width="LWPlaceholder"')
svgh = svgh.replace('stroke-width:0.01','stroke-width:LWPlaceholder') svgh = svgh.replace('stroke-width:0.01','stroke-width:LWPlaceholder')
svgh = svgh.replace('fill="none"','fill="none"\nstroke-dasharray="DAPlaceholder"') svgh = svgh.replace('fill="none"','fill="none"\nstroke-dasharray="DAPlaceholder"')
self.svg += svgh self.svg += svgh
if sshapes: if sshapes:
sshapes = Part.makeCompound(sshapes) sshapes = Part.makeCompound(sshapes)
@ -452,5 +453,5 @@ class _ArchDrawingView:
return result return result
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_SectionPlane',_CommandSectionPlane()) FreeCADGui.addCommand('Arch_SectionPlane',_CommandSectionPlane())

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -34,10 +34,11 @@ __title__="FreeCAD Site"
__author__ = "Yorik van Havre" __author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org" __url__ = "http://www.freecadweb.org"
def makeSite(objectslist=None,baseobj=None,name=translate("Arch","Site")): def makeSite(objectslist=None,baseobj=None,name="Site"):
'''makeBuilding(objectslist): creates a site including the '''makeBuilding(objectslist): creates a site including the
objects from the given list.''' objects from the given list.'''
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name) obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
obj.Label = translate("Arch",name)
_Site(obj) _Site(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderSite(obj.ViewObject) _ViewProviderSite(obj.ViewObject)
@ -57,7 +58,7 @@ class _CommandSite:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
def Activated(self): def Activated(self):
sel = FreeCADGui.Selection.getSelection() sel = FreeCADGui.Selection.getSelection()
ok = False ok = False
@ -97,16 +98,16 @@ class _Site(ArchFloor._Floor):
obj.addProperty("App::PropertyString","Url","Arch",translate("Arch","An url that shows this site in a mapping website")) obj.addProperty("App::PropertyString","Url","Arch",translate("Arch","An url that shows this site in a mapping website"))
self.Type = "Site" self.Type = "Site"
obj.setEditorMode('Height',2) obj.setEditorMode('Height',2)
class _ViewProviderSite(ArchFloor._ViewProviderFloor): class _ViewProviderSite(ArchFloor._ViewProviderFloor):
"A View Provider for the Site object" "A View Provider for the Site object"
def __init__(self,vobj): def __init__(self,vobj):
ArchFloor._ViewProviderFloor.__init__(self,vobj) ArchFloor._ViewProviderFloor.__init__(self,vobj)
def getIcon(self): def getIcon(self):
import Arch_rc import Arch_rc
return ":/icons/Arch_Site_Tree.svg" return ":/icons/Arch_Site_Tree.svg"
def claimChildren(self): def claimChildren(self):
return self.Object.Group+[self.Object.Terrain] return self.Object.Group+[self.Object.Terrain]

View File

@ -2,8 +2,8 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2013 * #* Copyright (c) 2013 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -38,11 +38,12 @@ else:
def translate(ctxt,txt): def translate(ctxt,txt):
return txt return txt
def makeSpace(objects=None,baseobj=None,name=translate("Arch","Space")): def makeSpace(objects=None,baseobj=None,name="Space"):
"""makeSpace([objects]): Creates a space object from the given objects. Objects can be one """makeSpace([objects]): Creates a space object from the given objects. Objects can be one
document object, in which case it becomes the base shape of the space object, or a list of document object, in which case it becomes the base shape of the space object, or a list of
selection objects as got from getSelectionEx(), or a list of tuples (object, subobjectname)""" selection objects as got from getSelectionEx(), or a list of tuples (object, subobjectname)"""
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_Space(obj) _Space(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderSpace(obj.ViewObject) _ViewProviderSpace(obj.ViewObject)
@ -57,13 +58,13 @@ def makeSpace(objects=None,baseobj=None,name=translate("Arch","Space")):
else: else:
obj.Proxy.addSubobjects(obj,objects) obj.Proxy.addSubobjects(obj,objects)
return obj return obj
def addSpaceBoundaries(space,subobjects): def addSpaceBoundaries(space,subobjects):
"""addSpaceBoundaries(space,subobjects): adds the given subobjects to the given space""" """addSpaceBoundaries(space,subobjects): adds the given subobjects to the given space"""
import Draft import Draft
if Draft.getType(space) == "Space": if Draft.getType(space) == "Space":
space.Proxy.addSubobjects(space,subobjects) space.Proxy.addSubobjects(space,subobjects)
def removeSpaceBoundaries(space,objects): def removeSpaceBoundaries(space,objects):
"""removeSpaceBoundaries(space,objects): removes the given objects from the given spaces boundaries""" """removeSpaceBoundaries(space,objects): removes the given objects from the given spaces boundaries"""
import Draft import Draft
@ -128,7 +129,7 @@ class _Space(ArchComponent.Component):
obj.Area = self.getArea(obj) obj.Area = self.getArea(obj)
if hasattr(obj,"Area"): if hasattr(obj,"Area"):
obj.setEditorMode('Area',1) obj.setEditorMode('Area',1)
def addSubobjects(self,obj,subobjects): def addSubobjects(self,obj,subobjects):
"adds subobjects to this space" "adds subobjects to this space"
objs = obj.Boundaries objs = obj.Boundaries
@ -148,10 +149,10 @@ class _Space(ArchComponent.Component):
import Part import Part
shape = None shape = None
faces = [] faces = []
#print "starting compute" #print "starting compute"
# 1: if we have a base shape, we use it # 1: if we have a base shape, we use it
if obj.Base: if obj.Base:
if obj.Base.isDerivedFrom("Part::Feature"): if obj.Base.isDerivedFrom("Part::Feature"):
if obj.Base.Shape.Solids: if obj.Base.Shape.Solids:
@ -174,7 +175,7 @@ class _Space(ArchComponent.Component):
return return
shape = Part.makeBox(bb.XLength,bb.YLength,bb.ZLength,FreeCAD.Vector(bb.XMin,bb.YMin,bb.ZMin)) shape = Part.makeBox(bb.XLength,bb.YLength,bb.ZLength,FreeCAD.Vector(bb.XMin,bb.YMin,bb.ZMin))
#print "created shape from boundbox" #print "created shape from boundbox"
# 3: identifing boundary faces # 3: identifing boundary faces
goodfaces = [] goodfaces = []
for b in obj.Boundaries: for b in obj.Boundaries:
@ -185,7 +186,7 @@ class _Space(ArchComponent.Component):
#print "adding face ",fn," of object ",b[0].Name #print "adding face ",fn," of object ",b[0].Name
#print "total: ", len(faces), " faces" #print "total: ", len(faces), " faces"
# 4: get cutvolumes from faces # 4: get cutvolumes from faces
cutvolumes = [] cutvolumes = []
for f in faces: for f in faces:
@ -199,7 +200,7 @@ class _Space(ArchComponent.Component):
for v in cutvolumes: for v in cutvolumes:
#print "cutting" #print "cutting"
shape = shape.cut(v) shape = shape.cut(v)
# 5: get the final shape # 5: get the final shape
if shape: if shape:
if shape.Solids: if shape.Solids:
@ -207,9 +208,9 @@ class _Space(ArchComponent.Component):
shape = shape.Solids[0] shape = shape.Solids[0]
obj.Shape = shape obj.Shape = shape
return return
print "Arch: error computing space boundary" print "Arch: error computing space boundary"
def getArea(self,obj): def getArea(self,obj):
"returns the horizontal area at the center of the space" "returns the horizontal area at the center of the space"
import Part,DraftGeomUtils import Part,DraftGeomUtils
@ -244,7 +245,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
vobj.addProperty("App::PropertyVector", "TextPosition","Arch",translate("Arch","The position of the text. Leave (0,0,0) for automatic position")) vobj.addProperty("App::PropertyVector", "TextPosition","Arch",translate("Arch","The position of the text. Leave (0,0,0) for automatic position"))
vobj.addProperty("App::PropertyEnumeration","TextAlign", "Arch",translate("Arch","The justification of the text")) vobj.addProperty("App::PropertyEnumeration","TextAlign", "Arch",translate("Arch","The justification of the text"))
vobj.addProperty("App::PropertyInteger", "Decimals", "Arch",translate("Arch","The number of decimals to use for calculated texts")) vobj.addProperty("App::PropertyInteger", "Decimals", "Arch",translate("Arch","The number of decimals to use for calculated texts"))
vobj.addProperty("App::PropertyBool", "ShowUnit", "Arch",translate("Arch","Show the unit suffix")) vobj.addProperty("App::PropertyBool", "ShowUnit", "Arch",translate("Arch","Show the unit suffix"))
vobj.TextColor = (0.0,0.0,0.0,1.0) vobj.TextColor = (0.0,0.0,0.0,1.0)
vobj.Text = ["$label","$area"] vobj.Text = ["$label","$area"]
vobj.TextAlign = ["Left","Center","Right"] vobj.TextAlign = ["Left","Center","Right"]
@ -254,10 +255,10 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
vobj.Decimals = Draft.getParam("dimPrecision",2) vobj.Decimals = Draft.getParam("dimPrecision",2)
vobj.ShowUnit = Draft.getParam("showUnit",True) vobj.ShowUnit = Draft.getParam("showUnit",True)
vobj.LineSpacing = 1.0 vobj.LineSpacing = 1.0
def getDefaultDisplayMode(self): def getDefaultDisplayMode(self):
return "Wireframe" return "Wireframe"
def getIcon(self): def getIcon(self):
import Arch_rc import Arch_rc
return ":/icons/Arch_Space_Tree.svg" return ":/icons/Arch_Space_Tree.svg"
@ -288,12 +289,12 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
self.onChanged(vobj,"FirstLine") self.onChanged(vobj,"FirstLine")
self.onChanged(vobj,"LineSpacing") self.onChanged(vobj,"LineSpacing")
self.onChanged(vobj,"FontName") self.onChanged(vobj,"FontName")
def updateData(self,obj,prop): def updateData(self,obj,prop):
if prop in ["Shape","Label","Tag"]: if prop in ["Shape","Label","Tag"]:
self.onChanged(obj.ViewObject,"Text") self.onChanged(obj.ViewObject,"Text")
self.onChanged(obj.ViewObject,"TextPosition") self.onChanged(obj.ViewObject,"TextPosition")
def getTextPosition(self,vobj): def getTextPosition(self,vobj):
pos = FreeCAD.Vector() pos = FreeCAD.Vector()
if hasattr(vobj,"TextPosition"): if hasattr(vobj,"TextPosition"):
@ -308,7 +309,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
else: else:
pos = vobj.TextPosition pos = vobj.TextPosition
return pos return pos
def onChanged(self,vobj,prop): def onChanged(self,vobj,prop):
if prop in ["Text","Decimals","ShowUnit"]: if prop in ["Text","Decimals","ShowUnit"]:
if hasattr(self,"text1") and hasattr(self,"text2") and hasattr(vobj,"Text"): if hasattr(self,"text1") and hasattr(self,"text2") and hasattr(vobj,"Text"):
@ -353,38 +354,38 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
self.text1.string.setValues(text1) self.text1.string.setValues(text1)
if text2: if text2:
self.text2.string.setValues(text2) self.text2.string.setValues(text2)
elif prop == "FontName": elif prop == "FontName":
if hasattr(self,"font") and hasattr(vobj,"FontName"): if hasattr(self,"font") and hasattr(vobj,"FontName"):
self.font.name = str(vobj.FontName) self.font.name = str(vobj.FontName)
elif (prop == "FontSize"): elif (prop == "FontSize"):
if hasattr(self,"font") and hasattr(vobj,"FontSize"): if hasattr(self,"font") and hasattr(vobj,"FontSize"):
self.font.size = vobj.FontSize.Value self.font.size = vobj.FontSize.Value
elif (prop == "FirstLine"): elif (prop == "FirstLine"):
if hasattr(self,"header") and hasattr(vobj,"FontSize") and hasattr(vobj,"FirstLine"): if hasattr(self,"header") and hasattr(vobj,"FontSize") and hasattr(vobj,"FirstLine"):
scale = vobj.FirstLine.Value/vobj.FontSize.Value scale = vobj.FirstLine.Value/vobj.FontSize.Value
self.header.scaleFactor.setValue([scale,scale,scale]) self.header.scaleFactor.setValue([scale,scale,scale])
elif prop == "TextColor": elif prop == "TextColor":
if hasattr(self,"color") and hasattr(vobj,"TextColor"): if hasattr(self,"color") and hasattr(vobj,"TextColor"):
c = vobj.TextColor c = vobj.TextColor
self.color.rgb.setValue(c[0],c[1],c[2]) self.color.rgb.setValue(c[0],c[1],c[2])
elif prop == "TextPosition": elif prop == "TextPosition":
if hasattr(self,"coords") and hasattr(self,"header") and hasattr(vobj,"TextPosition") and hasattr(vobj,"FirstLine"): if hasattr(self,"coords") and hasattr(self,"header") and hasattr(vobj,"TextPosition") and hasattr(vobj,"FirstLine"):
pos = self.getTextPosition(vobj) pos = self.getTextPosition(vobj)
self.coords.translation.setValue([pos.x,pos.y,pos.z]) self.coords.translation.setValue([pos.x,pos.y,pos.z])
up = vobj.FirstLine.Value * vobj.LineSpacing up = vobj.FirstLine.Value * vobj.LineSpacing
self.header.translation.setValue([0,up,0]) self.header.translation.setValue([0,up,0])
elif prop == "LineSpacing": elif prop == "LineSpacing":
if hasattr(self,"text1") and hasattr(self,"text2") and hasattr(vobj,"LineSpacing"): if hasattr(self,"text1") and hasattr(self,"text2") and hasattr(vobj,"LineSpacing"):
self.text1.spacing = vobj.LineSpacing self.text1.spacing = vobj.LineSpacing
self.text2.spacing = vobj.LineSpacing self.text2.spacing = vobj.LineSpacing
self.onChanged(vobj,"TextPosition") self.onChanged(vobj,"TextPosition")
elif prop == "TextAlign": elif prop == "TextAlign":
if hasattr(self,"text1") and hasattr(self,"text2") and hasattr(vobj,"TextAlign"): if hasattr(self,"text1") and hasattr(self,"text2") and hasattr(vobj,"TextAlign"):
from pivy import coin from pivy import coin
@ -397,7 +398,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
else: else:
self.text1.justification = coin.SoAsciiText.LEFT self.text1.justification = coin.SoAsciiText.LEFT
self.text2.justification = coin.SoAsciiText.LEFT self.text2.justification = coin.SoAsciiText.LEFT

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2013 * #* Copyright (c) 2013 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -36,11 +36,12 @@ else:
return txt return txt
def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name=translate("Arch","Stairs")): def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name="Stairs"):
"""makeStairs([baseobj,length,width,height,steps]): creates a Stairs """makeStairs([baseobj,length,width,height,steps]): creates a Stairs
objects with given attributes.""" objects with given attributes."""
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_Stairs(obj) _Stairs(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderStairs(obj.ViewObject) _ViewProviderStairs(obj.ViewObject)
@ -91,15 +92,15 @@ class _Stairs(ArchComponent.Component):
"A stairs object" "A stairs object"
def __init__(self,obj): def __init__(self,obj):
ArchComponent.Component.__init__(self,obj) ArchComponent.Component.__init__(self,obj)
# http://en.wikipedia.org/wiki/Stairs # http://en.wikipedia.org/wiki/Stairs
# base properties # base properties
obj.addProperty("App::PropertyLength","Length","Arch",translate("Arch","The length of these stairs, if no baseline is defined")) obj.addProperty("App::PropertyLength","Length","Arch",translate("Arch","The length of these stairs, if no baseline is defined"))
obj.addProperty("App::PropertyLength","Width","Arch",translate("Arch","The width of these stairs")) obj.addProperty("App::PropertyLength","Width","Arch",translate("Arch","The width of these stairs"))
obj.addProperty("App::PropertyLength","Height","Arch",translate("Arch","The total height of these stairs")) obj.addProperty("App::PropertyLength","Height","Arch",translate("Arch","The total height of these stairs"))
obj.addProperty("App::PropertyEnumeration","Align","Arch",translate("Arch","The alignment of these stairs on their baseline, if applicable")) obj.addProperty("App::PropertyEnumeration","Align","Arch",translate("Arch","The alignment of these stairs on their baseline, if applicable"))
# steps properties # steps properties
obj.addProperty("App::PropertyInteger","NumberOfSteps","Steps",translate("Arch","The number of risers in these stairs")) obj.addProperty("App::PropertyInteger","NumberOfSteps","Steps",translate("Arch","The number of risers in these stairs"))
obj.addProperty("App::PropertyLength","TreadDepth","Steps",translate("Arch","The depth of the treads of these stairs")) obj.addProperty("App::PropertyLength","TreadDepth","Steps",translate("Arch","The depth of the treads of these stairs"))
@ -107,7 +108,7 @@ class _Stairs(ArchComponent.Component):
obj.addProperty("App::PropertyLength","Nosing","Steps",translate("Arch","The size of the nosing")) obj.addProperty("App::PropertyLength","Nosing","Steps",translate("Arch","The size of the nosing"))
obj.addProperty("App::PropertyLength","TreadThickness","Steps",translate("Arch","The thickness of the treads")) obj.addProperty("App::PropertyLength","TreadThickness","Steps",translate("Arch","The thickness of the treads"))
obj.addProperty("App::PropertyFloat","BlondelRatio","Steps",translate("Arch","The Blondel ratio, must be between 62 and 64cm or 24.5 and 25.5in")) obj.addProperty("App::PropertyFloat","BlondelRatio","Steps",translate("Arch","The Blondel ratio, must be between 62 and 64cm or 24.5 and 25.5in"))
# structural properties # structural properties
obj.addProperty("App::PropertyEnumeration","Landings","Structure",translate("Arch","The type of landings of these stairs")) obj.addProperty("App::PropertyEnumeration","Landings","Structure",translate("Arch","The type of landings of these stairs"))
obj.addProperty("App::PropertyEnumeration","Winders","Structure",translate("Arch","The type of winders in these stairs")) obj.addProperty("App::PropertyEnumeration","Winders","Structure",translate("Arch","The type of winders in these stairs"))
@ -115,7 +116,7 @@ class _Stairs(ArchComponent.Component):
obj.addProperty("App::PropertyLength","StructureThickness","Structure",translate("Arch","The thickness of the massive structure or of the stringers")) obj.addProperty("App::PropertyLength","StructureThickness","Structure",translate("Arch","The thickness of the massive structure or of the stringers"))
obj.addProperty("App::PropertyLength","StringerWidth","Structure",translate("Arch","The width of the stringers")) obj.addProperty("App::PropertyLength","StringerWidth","Structure",translate("Arch","The width of the stringers"))
obj.addProperty("App::PropertyLength","StructureOffset","Structure",translate("Arch","The offset between the border of the stairs and the structure")) obj.addProperty("App::PropertyLength","StructureOffset","Structure",translate("Arch","The offset between the border of the stairs and the structure"))
obj.Align = ['Left','Right','Center'] obj.Align = ['Left','Right','Center']
obj.Landings = ["None","At center","At each corner"] obj.Landings = ["None","At center","At each corner"]
obj.Winders = ["None","All","Corners strict","Corners relaxed"] obj.Winders = ["None","All","Corners strict","Corners relaxed"]
@ -136,9 +137,9 @@ class _Stairs(ArchComponent.Component):
self.structures = [] self.structures = []
pl = obj.Placement pl = obj.Placement
landings = 0 landings = 0
base = None base = None
if obj.Base: if obj.Base:
if hasattr(obj.Base,"Shape"): if hasattr(obj.Base,"Shape"):
if obj.Base.Shape: if obj.Base.Shape:
@ -159,12 +160,12 @@ class _Stairs(ArchComponent.Component):
return return
if obj.Base.Shape.Faces: if obj.Base.Shape.Faces:
return return
if (len(obj.Base.Shape.Edges) == 1): if (len(obj.Base.Shape.Edges) == 1):
edge = obj.Base.Shape.Edges[0] edge = obj.Base.Shape.Edges[0]
if isinstance(edge.Curve,Part.Line): if isinstance(edge.Curve,Part.Line):
if obj.Landings == "At center": if obj.Landings == "At center":
landings = 1 landings = 1
self.makeStraightStairsWithLanding(obj,edge) self.makeStraightStairsWithLanding(obj,edge)
else: else:
self.makeStraightStairs(obj,edge) self.makeStraightStairs(obj,edge)
else: else:
@ -190,13 +191,13 @@ class _Stairs(ArchComponent.Component):
obj.Shape = shape obj.Shape = shape
obj.Placement = pl obj.Placement = pl
return return
base = self.processSubShapes(obj,base,pl) base = self.processSubShapes(obj,base,pl)
if base: if base:
if not base.isNull(): if not base.isNull():
obj.Shape = base obj.Shape = base
obj.Placement = pl obj.Placement = pl
# compute step data # compute step data
if obj.NumberOfSteps > 1: if obj.NumberOfSteps > 1:
l = obj.Length.Value l = obj.Length.Value
@ -441,7 +442,7 @@ class _Stairs(ArchComponent.Component):
def makeStraightStairsWithLanding(self,obj,edge): def makeStraightStairsWithLanding(self,obj,edge):
"builds a straight staircase with a landing in the middle" "builds a straight staircase with a landing in the middle"
if obj.NumberOfSteps < 3: if obj.NumberOfSteps < 3:
@ -479,7 +480,7 @@ class _ViewProviderStairs(ArchComponent.ViewProviderComponent):
"A View Provider for Stairs" "A View Provider for Stairs"
def __init__(self,vobj): def __init__(self,vobj):
ArchComponent.ViewProviderComponent.__init__(self,vobj) ArchComponent.ViewProviderComponent.__init__(self,vobj)
def getIcon(self): def getIcon(self):
import Arch_rc import Arch_rc
return ":/icons/Arch_Stairs_Tree.svg" return ":/icons/Arch_Stairs_Tree.svg"

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -47,7 +47,7 @@ Roles = ["Beam","Column","Slab","Wall","Curtain Wall","Roof","Foundation","Pile"
Presets = [None, Presets = [None,
# wood sections # wood sections
["Wood","1x2in",19,28], ["Wood","1x2in",19,28],
["Wood","1x3in",19,64], ["Wood","1x3in",19,64],
["Wood","1x4in",19,89], ["Wood","1x4in",19,89],
@ -55,7 +55,7 @@ Presets = [None,
["Wood","1x8in",19,140], ["Wood","1x8in",19,140],
["Wood","1x10in",19,184], ["Wood","1x10in",19,184],
["Wood","1x12in",19,286], ["Wood","1x12in",19,286],
["Wood","2x2in",38,38], ["Wood","2x2in",38,38],
["Wood","2x3in",38,64], ["Wood","2x3in",38,64],
["Wood","2x4in",38,89], ["Wood","2x4in",38,89],
@ -63,15 +63,15 @@ Presets = [None,
["Wood","2x8in",38,184], ["Wood","2x8in",38,184],
["Wood","2x10in",38,235], ["Wood","2x10in",38,235],
["Wood","2x12in",38,286], ["Wood","2x12in",38,286],
["Wood","4x4in",89,89], ["Wood","4x4in",89,89],
["Wood","4x6in",89,140], ["Wood","4x6in",89,140],
["Wood","6x6in",140,140], ["Wood","6x6in",140,140],
["Wood","8x8in",184,184], ["Wood","8x8in",184,184],
# HEA # HEA
["Steel","HEA100",100,96,5,8], ["Steel","HEA100",100,96,5,8],
["Steel","HEA120",120,114,5,8], ["Steel","HEA120",120,114,5,8],
["Steel","HEA140",140,133,5.5,8.5], ["Steel","HEA140",140,133,5.5,8.5],
@ -96,9 +96,9 @@ Presets = [None,
["Steel","HEA800",300,790,15,28], ["Steel","HEA800",300,790,15,28],
["Steel","HEA900",300,890,16,30], ["Steel","HEA900",300,890,16,30],
["Steel","HEA1000",300,990,16.5,31], ["Steel","HEA1000",300,990,16.5,31],
# HEAA # HEAA
["Steel","HEAA100",100,91,4.2,5.5], ["Steel","HEAA100",100,91,4.2,5.5],
["Steel","HEAA120",120,109,4.2,5.5], ["Steel","HEAA120",120,109,4.2,5.5],
["Steel","HEAA140",140,128,4.3,6], ["Steel","HEAA140",140,128,4.3,6],
@ -123,9 +123,9 @@ Presets = [None,
["Steel","HEAA800",300,770,14,18], ["Steel","HEAA800",300,770,14,18],
["Steel","HEAA900",300,870,15,20], ["Steel","HEAA900",300,870,15,20],
["Steel","HEAA1000",300,970,16,21], ["Steel","HEAA1000",300,970,16,21],
# HEB # HEB
["Steel","HEB100",100,100,6,10], ["Steel","HEB100",100,100,6,10],
["Steel","HEB120",120,120,6.5,11], ["Steel","HEB120",120,120,6.5,11],
["Steel","HEB140",140,140,7,12], ["Steel","HEB140",140,140,7,12],
@ -150,9 +150,9 @@ Presets = [None,
["Steel","HEB800",300,800,17.5,33], ["Steel","HEB800",300,800,17.5,33],
["Steel","HEB900",300,900,18.5,35], ["Steel","HEB900",300,900,18.5,35],
["Steel","HEB1000",300,1000,19,36], ["Steel","HEB1000",300,1000,19,36],
# HEM # HEM
["Steel","HEM160",166,180,14,23], ["Steel","HEM160",166,180,14,23],
["Steel","HEM180",186,200,14.5,24], ["Steel","HEM180",186,200,14.5,24],
["Steel","HEM200",206,220,15,25], ["Steel","HEM200",206,220,15,25],
@ -174,9 +174,9 @@ Presets = [None,
["Steel","HEM800",303,814,21,40], ["Steel","HEM800",303,814,21,40],
["Steel","HEM900",302,910,21,40], ["Steel","HEM900",302,910,21,40],
["Steel","HEM1000",302,1008,21,40], ["Steel","HEM1000",302,1008,21,40],
# INP # INP
["Steel","INP80",42,80,3.9,5.9], ["Steel","INP80",42,80,3.9,5.9],
["Steel","INP100",50,100,4.5,6.8], ["Steel","INP100",50,100,4.5,6.8],
["Steel","INP120",58,120,5.1,7.7], ["Steel","INP120",58,120,5.1,7.7],
@ -195,8 +195,8 @@ Presets = [None,
["Steel","INP380",149,380,13.7,20.5], ["Steel","INP380",149,380,13.7,20.5],
["Steel","INP400",155,400,14.4,21.6], ["Steel","INP400",155,400,14.4,21.6],
# IPE # IPE
["Steel","IPE100",55,100,4.1,5.7], ["Steel","IPE100",55,100,4.1,5.7],
["Steel","IPE120",64,120,4.4,6.3], ["Steel","IPE120",64,120,4.4,6.3],
["Steel","IPE140",73,140,4.7,6.9], ["Steel","IPE140",73,140,4.7,6.9],
@ -214,9 +214,9 @@ Presets = [None,
["Steel","IPE500",200,500,10.2,16], ["Steel","IPE500",200,500,10.2,16],
["Steel","IPE550",210,550,11.1,17.2], ["Steel","IPE550",210,550,11.1,17.2],
["Steel","IPE600",220,600,12,19], ["Steel","IPE600",220,600,12,19],
# IPEA # IPEA
["Steel","IPEA100",55,98,3.6,4.7], ["Steel","IPEA100",55,98,3.6,4.7],
["Steel","IPEA120",64,118,3.8,5.1], ["Steel","IPEA120",64,118,3.8,5.1],
["Steel","IPEA140",73,138,3.8,5.6], ["Steel","IPEA140",73,138,3.8,5.6],
@ -234,9 +234,9 @@ Presets = [None,
["Steel","IPEA500",200,497,8.4,14.5], ["Steel","IPEA500",200,497,8.4,14.5],
["Steel","IPEA550",210,547,9,15.7], ["Steel","IPEA550",210,547,9,15.7],
["Steel","IPEA600",220,597,9.8,17.5], ["Steel","IPEA600",220,597,9.8,17.5],
# IPEO # IPEO
["Steel","IPEO180",89,182,6.4,9.5], ["Steel","IPEO180",89,182,6.4,9.5],
["Steel","IPEO200",102,202,6.2,9.5], ["Steel","IPEO200",102,202,6.2,9.5],
["Steel","IPEO220",112,222,6.6,10.2], ["Steel","IPEO220",112,222,6.6,10.2],
@ -250,9 +250,9 @@ Presets = [None,
["Steel","IPEO500",202,506,12,19], ["Steel","IPEO500",202,506,12,19],
["Steel","IPEO550",212,556,12.7,20.2], ["Steel","IPEO550",212,556,12.7,20.2],
["Steel","IPEO600",224,610,15,24], ["Steel","IPEO600",224,610,15,24],
# IPER # IPER
["Steel","IPER140",72,142,5.3,7.8], ["Steel","IPER140",72,142,5.3,7.8],
["Steel","IPER160",81,162,5.6,8.5], ["Steel","IPER160",81,162,5.6,8.5],
["Steel","IPER180",92,183,6,9], ["Steel","IPER180",92,183,6,9],
@ -268,9 +268,9 @@ Presets = [None,
["Steel","IPER500",198,508,12.6,20], ["Steel","IPER500",198,508,12.6,20],
["Steel","IPER550",210,560,14,22.2], ["Steel","IPER550",210,560,14,22.2],
["Steel","IPER600",218,608,14,23], ["Steel","IPER600",218,608,14,23],
# IPEV # IPEV
["Steel","IPEV400",182,408,10.6,17.5], ["Steel","IPEV400",182,408,10.6,17.5],
["Steel","IPEV450",194,460,12.4,19.6], ["Steel","IPEV450",194,460,12.4,19.6],
["Steel","IPEV500",204,514,14.2,23], ["Steel","IPEV500",204,514,14.2,23],
@ -287,13 +287,14 @@ Presets = [None,
] ]
def makeStructure(baseobj=None,length=None,width=None,height=None,name=translate("Arch","Structure")): def makeStructure(baseobj=None,length=None,width=None,height=None,name="Structure"):
'''makeStructure([obj],[length],[width],[heigth],[swap]): creates a '''makeStructure([obj],[length],[width],[heigth],[swap]): creates a
structure element based on the given profile object and the given structure element based on the given profile object and the given
extrusion height. If no base object is given, you can also specify extrusion height. If no base object is given, you can also specify
length and width for a cubic object.''' length and width for a cubic object.'''
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_Structure(obj) _Structure(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderStructure(obj.ViewObject) _ViewProviderStructure(obj.ViewObject)
@ -321,7 +322,7 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name=translate
obj.Role = "Column" obj.Role = "Column"
return obj return obj
def makeStructuralSystem(objects=[],axes=[],name=translate("Arch","StructuralSystem")): def makeStructuralSystem(objects=[],axes=[],name="StructuralSystem"):
'''makeStructuralSystem(objects,axes): makes a structural system '''makeStructuralSystem(objects,axes): makes a structural system
based on the given objects and axes''' based on the given objects and axes'''
result = [] result = []
@ -335,6 +336,7 @@ def makeStructuralSystem(objects=[],axes=[],name=translate("Arch","StructuralSys
objects = [None] objects = [None]
for o in objects: for o in objects:
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_StructuralSystem(obj) _StructuralSystem(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderStructuralSystem(obj.ViewObject) _ViewProviderStructuralSystem(obj.ViewObject)
@ -350,14 +352,15 @@ def makeStructuralSystem(objects=[],axes=[],name=translate("Arch","StructuralSys
return result[0] return result[0]
else: else:
return result return result
def makeProfile(W=46,H=80,tw=3.8,tf=5.2,name="Profile"): def makeProfile(W=46,H=80,tw=3.8,tf=5.2,name="Profile"):
'''makeProfile(W,H,tw,tf): returns a shape with one face describing '''makeProfile(W,H,tw,tf): returns a shape with one face describing
the profile of a steel beam (IPE, IPN, HE, etc...) based on the following the profile of a steel beam (IPE, IPN, HE, etc...) based on the following
dimensions: W = total width, H = total height, tw = web thickness dimensions: W = total width, H = total height, tw = web thickness
tw = flange thickness (see http://en.wikipedia.org/wiki/I-beam for tw = flange thickness (see http://en.wikipedia.org/wiki/I-beam for
reference)''' reference)'''
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",name) obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",name)
obj.Label = translate("Arch",name)
_Profile(obj) _Profile(obj)
obj.Width = W obj.Width = W
obj.Height = H obj.Height = H
@ -377,8 +380,8 @@ class _CommandStructure:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
def Activated(self): def Activated(self):
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
self.Length = p.GetFloat("StructureLength",100) self.Length = p.GetFloat("StructureLength",100)
self.Width = p.GetFloat("StructureWidth",100) self.Width = p.GetFloat("StructureWidth",100)
@ -422,7 +425,7 @@ class _CommandStructure:
self.tracker.length(self.Length) self.tracker.length(self.Length)
self.tracker.on() self.tracker.on()
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox()) FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox())
def getPoint(self,point=None,obj=None): def getPoint(self,point=None,obj=None):
"this function is called by the snapper when it has a 3D point" "this function is called by the snapper when it has a 3D point"
self.tracker.finalize() self.tracker.finalize()
@ -456,7 +459,7 @@ class _CommandStructure:
ui = FreeCADGui.UiLoader() ui = FreeCADGui.UiLoader()
w.setWindowTitle(translate("Arch","Structure options").decode("utf8")) w.setWindowTitle(translate("Arch","Structure options").decode("utf8"))
grid = QtGui.QGridLayout(w) grid = QtGui.QGridLayout(w)
# presets box # presets box
labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8")) labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8"))
valuep = QtGui.QComboBox() valuep = QtGui.QComboBox()
@ -466,14 +469,14 @@ class _CommandStructure:
valuep.addItems(fpresets) valuep.addItems(fpresets)
grid.addWidget(labelp,0,0,1,1) grid.addWidget(labelp,0,0,1,1)
grid.addWidget(valuep,0,1,1,1) grid.addWidget(valuep,0,1,1,1)
# length # length
label1 = QtGui.QLabel(translate("Arch","Length").decode("utf8")) label1 = QtGui.QLabel(translate("Arch","Length").decode("utf8"))
self.vLength = ui.createWidget("Gui::InputField") self.vLength = ui.createWidget("Gui::InputField")
self.vLength.setText(self.FORMAT % self.Length) self.vLength.setText(self.FORMAT % self.Length)
grid.addWidget(label1,1,0,1,1) grid.addWidget(label1,1,0,1,1)
grid.addWidget(self.vLength,1,1,1,1) grid.addWidget(self.vLength,1,1,1,1)
# width # width
label2 = QtGui.QLabel(translate("Arch","Width").decode("utf8")) label2 = QtGui.QLabel(translate("Arch","Width").decode("utf8"))
self.vWidth = ui.createWidget("Gui::InputField") self.vWidth = ui.createWidget("Gui::InputField")
@ -487,7 +490,7 @@ class _CommandStructure:
self.vHeight.setText(self.FORMAT % self.Height) self.vHeight.setText(self.FORMAT % self.Height)
grid.addWidget(label3,3,0,1,1) grid.addWidget(label3,3,0,1,1)
grid.addWidget(self.vHeight,3,1,1,1) grid.addWidget(self.vHeight,3,1,1,1)
# horizontal button # horizontal button
value5 = QtGui.QPushButton(translate("Arch","Rotate").decode("utf8")) value5 = QtGui.QPushButton(translate("Arch","Rotate").decode("utf8"))
grid.addWidget(value5,4,0,1,2) grid.addWidget(value5,4,0,1,2)
@ -511,7 +514,7 @@ class _CommandStructure:
QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue) QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
QtCore.QObject.connect(value5,QtCore.SIGNAL("pressed()"),self.rotate) QtCore.QObject.connect(value5,QtCore.SIGNAL("pressed()"),self.rotate)
return w return w
def update(self,point,info): def update(self,point,info):
"this function is called by the Snapper when the mouse is moved" "this function is called by the Snapper when the mouse is moved"
if FreeCADGui.Control.activeDialog(): if FreeCADGui.Control.activeDialog():
@ -520,7 +523,7 @@ class _CommandStructure:
else: else:
delta = Vector(self.Length/2,0,0) delta = Vector(self.Length/2,0,0)
self.tracker.pos(point.add(delta)) self.tracker.pos(point.add(delta))
def setWidth(self,d): def setWidth(self,d):
self.Width = d self.Width = d
self.tracker.width(d) self.tracker.width(d)
@ -537,7 +540,7 @@ class _CommandStructure:
self.continueCmd = bool(i) self.continueCmd = bool(i)
if hasattr(FreeCADGui,"draftToolBar"): if hasattr(FreeCADGui,"draftToolBar"):
FreeCADGui.draftToolBar.continueMode = bool(i) FreeCADGui.draftToolBar.continueMode = bool(i)
def setPreset(self,i): def setPreset(self,i):
if i > 0: if i > 0:
self.vLength.setText(self.FORMAT % float(Presets[i][2])) self.vLength.setText(self.FORMAT % float(Presets[i][2]))
@ -546,7 +549,7 @@ class _CommandStructure:
self.Profile = i self.Profile = i
else: else:
self.Profile = 0 self.Profile = 0
def rotate(self): def rotate(self):
l = self.Length l = self.Length
w = self.Width w = self.Width
@ -554,7 +557,7 @@ class _CommandStructure:
self.vLength.setText(self.FORMAT % h) self.vLength.setText(self.FORMAT % h)
self.vHeight.setText(self.FORMAT % w) self.vHeight.setText(self.FORMAT % w)
self.vWidth.setText(self.FORMAT % l) self.vWidth.setText(self.FORMAT % l)
class _Structure(ArchComponent.Component): class _Structure(ArchComponent.Component):
"The Structure object" "The Structure object"
def __init__(self,obj): def __init__(self,obj):
@ -569,12 +572,12 @@ class _Structure(ArchComponent.Component):
obj.addProperty("App::PropertyString","Profile","Arch",translate("Arch","A description of the standard profile this element is based upon")) obj.addProperty("App::PropertyString","Profile","Arch",translate("Arch","A description of the standard profile this element is based upon"))
self.Type = "Structure" self.Type = "Structure"
obj.Role = Roles obj.Role = Roles
def execute(self,obj): def execute(self,obj):
"creates the structure shape" "creates the structure shape"
import Part, DraftGeomUtils import Part, DraftGeomUtils
normal,length,width,height = self.getDefaultValues(obj) normal,length,width,height = self.getDefaultValues(obj)
# creating base shape # creating base shape
@ -613,7 +616,7 @@ class _Structure(ArchComponent.Component):
if base.Wires[0].isClosed(): if base.Wires[0].isClosed():
base = Part.Face(base.Wires[0]) base = Part.Face(base.Wires[0])
base = base.extrude(normal) base = base.extrude(normal)
elif obj.Base.isDerivedFrom("Mesh::Feature"): elif obj.Base.isDerivedFrom("Mesh::Feature"):
if obj.Base.Mesh.isSolid(): if obj.Base.Mesh.isSolid():
if obj.Base.Mesh.countComponents() == 1: if obj.Base.Mesh.countComponents() == 1:
@ -632,7 +635,7 @@ class _Structure(ArchComponent.Component):
normal = normal.multiply(height) normal = normal.multiply(height)
base = Part.Face(base[0]) base = Part.Face(base[0])
base = base.extrude(normal) base = base.extrude(normal)
base = self.processSubShapes(obj,base,pl) base = self.processSubShapes(obj,base,pl)
self.applyShape(obj,base,pl) self.applyShape(obj,base,pl)
@ -676,7 +679,7 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
def getIcon(self): def getIcon(self):
import Arch_rc import Arch_rc
return ":/icons/Arch_Structure_Tree.svg" return ":/icons/Arch_Structure_Tree.svg"
def updateData(self,obj,prop): def updateData(self,obj,prop):
if prop == "Nodes": if prop == "Nodes":
if obj.Nodes: if obj.Nodes:
@ -687,7 +690,7 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
self.coords.point.setValues(0,len(p),p) self.coords.point.setValues(0,len(p),p)
self.pointset.numPoints.setValue(len(p)) self.pointset.numPoints.setValue(len(p))
self.lineset.coordIndex.setValues(0,len(p)+1,range(len(p))+[-1]) self.lineset.coordIndex.setValues(0,len(p)+1,range(len(p))+[-1])
def onChanged(self,vobj,prop): def onChanged(self,vobj,prop):
if prop == "ShowNodes": if prop == "ShowNodes":
if hasattr(self,"nodes"): if hasattr(self,"nodes"):
@ -729,14 +732,14 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
class _Profile(Draft._DraftObject): class _Profile(Draft._DraftObject):
"A parametric beam profile object" "A parametric beam profile object"
def __init__(self,obj): def __init__(self,obj):
obj.addProperty("App::PropertyLength","Width","Draft","Width of the beam").Width = 10 obj.addProperty("App::PropertyLength","Width","Draft","Width of the beam").Width = 10
obj.addProperty("App::PropertyLength","Height","Draft","Height of the beam").Height = 30 obj.addProperty("App::PropertyLength","Height","Draft","Height of the beam").Height = 30
obj.addProperty("App::PropertyLength","WebThickness","Draft","Thickness of the webs").WebThickness = 3 obj.addProperty("App::PropertyLength","WebThickness","Draft","Thickness of the webs").WebThickness = 3
obj.addProperty("App::PropertyLength","FlangeThickness","Draft","Thickness of the flange").FlangeThickness = 2 obj.addProperty("App::PropertyLength","FlangeThickness","Draft","Thickness of the flange").FlangeThickness = 2
Draft._DraftObject.__init__(self,obj,"Profile") Draft._DraftObject.__init__(self,obj,"Profile")
def execute(self,obj): def execute(self,obj):
import Part import Part
pl = obj.Placement pl = obj.Placement
@ -764,12 +767,12 @@ class _StructuralSystem(ArchComponent.Component):
obj.addProperty("App::PropertyLinkList","Axes","Arch",translate("Arch","Axes systems this structure is built on")) obj.addProperty("App::PropertyLinkList","Axes","Arch",translate("Arch","Axes systems this structure is built on"))
obj.addProperty("App::PropertyIntegerList","Exclude","Arch",translate("Arch","The element numbers to exclude when this structure is based on axes")) obj.addProperty("App::PropertyIntegerList","Exclude","Arch",translate("Arch","The element numbers to exclude when this structure is based on axes"))
self.Type = "StructuralSystem" self.Type = "StructuralSystem"
def execute(self,obj): def execute(self,obj):
"creates the structure shape" "creates the structure shape"
import Part, DraftGeomUtils import Part, DraftGeomUtils
# creating base shape # creating base shape
pl = obj.Placement pl = obj.Placement
if obj.Base: if obj.Base:
@ -780,7 +783,7 @@ class _StructuralSystem(ArchComponent.Component):
return return
base = None base = None
# applying axes # applying axes
pts = self.getAxisPoints(obj) pts = self.getAxisPoints(obj)
apl = self.getAxisPlacement(obj) apl = self.getAxisPlacement(obj)
@ -813,7 +816,7 @@ class _StructuralSystem(ArchComponent.Component):
obj.Shape = base obj.Shape = base
if not pl.isNull(): if not pl.isNull():
obj.Placement = pl obj.Placement = pl
def getAxisPoints(self,obj): def getAxisPoints(self,obj):
"returns the gridpoints of linked axes" "returns the gridpoints of linked axes"
import DraftGeomUtils import DraftGeomUtils
@ -825,7 +828,7 @@ class _StructuralSystem(ArchComponent.Component):
set1 = obj.Axes[0].Shape.Edges set1 = obj.Axes[0].Shape.Edges
set2 = obj.Axes[1].Shape.Edges set2 = obj.Axes[1].Shape.Edges
for e1 in set1: for e1 in set1:
for e2 in set2: for e2 in set2:
pts.extend(DraftGeomUtils.findIntersection(e1,e2)) pts.extend(DraftGeomUtils.findIntersection(e1,e2))
return pts return pts

View File

@ -1,7 +1,7 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> * #* Yorik van Havre <yorik@uncreated.net> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -38,13 +38,14 @@ __url__ = "http://www.freecadweb.org"
# Possible roles for walls # Possible roles for walls
Roles = ['Wall','Wall Layer','Beam','Column','Curtain Wall'] Roles = ['Wall','Wall Layer','Beam','Column','Curtain Wall']
def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face=None,name=translate("Arch","Wall")): def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face=None,name="Wall"):
'''makeWall([obj],[length],[width],[height],[align],[face],[name]): creates a wall based on the '''makeWall([obj],[length],[width],[height],[align],[face],[name]): creates a wall based on the
given object, which can be a sketch, a draft object, a face or a solid, or no object at given object, which can be a sketch, a draft object, a face or a solid, or no object at
all, then you must provide length, width and height. Align can be "Center","Left" or "Right", all, then you must provide length, width and height. Align can be "Center","Left" or "Right",
face can be an index number of a face in the base object to base the wall on.''' face can be an index number of a face in the base object to base the wall on.'''
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = translate("Arch",name)
_Wall(obj) _Wall(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderWall(obj.ViewObject) _ViewProviderWall(obj.ViewObject)
@ -101,7 +102,7 @@ def joinWalls(walls,delete=False):
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
base.ViewObject.show() base.ViewObject.show()
return base return base
def mergeShapes(w1,w2): def mergeShapes(w1,w2):
"returns a Shape built on two walls that share same properties and have a coincident endpoint" "returns a Shape built on two walls that share same properties and have a coincident endpoint"
if not areSameWallTypes([w1,w2]): if not areSameWallTypes([w1,w2]):
@ -110,10 +111,10 @@ def mergeShapes(w1,w2):
return None return None
if w1.Base.Shape.Faces or w2.Base.Shape.Faces: if w1.Base.Shape.Faces or w2.Base.Shape.Faces:
return None return None
# TODO fix this # TODO fix this
return None return None
eds = w1.Base.Shape.Edges + w2.Base.Shape.Edges eds = w1.Base.Shape.Edges + w2.Base.Shape.Edges
import DraftGeomUtils import DraftGeomUtils
w = DraftGeomUtils.findWires(eds) w = DraftGeomUtils.findWires(eds)
@ -154,7 +155,7 @@ class _CommandWall:
def IsActive(self): def IsActive(self):
return not FreeCAD.ActiveDocument is None return not FreeCAD.ActiveDocument is None
def Activated(self): def Activated(self):
self.Align = "Center" self.Align = "Center"
self.Length = None self.Length = None
@ -281,25 +282,25 @@ class _CommandWall:
ui = FreeCADGui.UiLoader() ui = FreeCADGui.UiLoader()
w.setWindowTitle(translate("Arch","Wall options").decode("utf8")) w.setWindowTitle(translate("Arch","Wall options").decode("utf8"))
grid = QtGui.QGridLayout(w) grid = QtGui.QGridLayout(w)
label5 = QtGui.QLabel(translate("Arch","Length").decode("utf8")) label5 = QtGui.QLabel(translate("Arch","Length").decode("utf8"))
self.Length = ui.createWidget("Gui::InputField") self.Length = ui.createWidget("Gui::InputField")
self.Length.setText("0.00 mm") self.Length.setText("0.00 mm")
grid.addWidget(label5,0,0,1,1) grid.addWidget(label5,0,0,1,1)
grid.addWidget(self.Length,0,1,1,1) grid.addWidget(self.Length,0,1,1,1)
label1 = QtGui.QLabel(translate("Arch","Width").decode("utf8")) label1 = QtGui.QLabel(translate("Arch","Width").decode("utf8"))
value1 = ui.createWidget("Gui::InputField") value1 = ui.createWidget("Gui::InputField")
value1.setText(self.FORMAT % self.Width) value1.setText(self.FORMAT % self.Width)
grid.addWidget(label1,1,0,1,1) grid.addWidget(label1,1,0,1,1)
grid.addWidget(value1,1,1,1,1) grid.addWidget(value1,1,1,1,1)
label2 = QtGui.QLabel(translate("Arch","Height").decode("utf8")) label2 = QtGui.QLabel(translate("Arch","Height").decode("utf8"))
value2 = ui.createWidget("Gui::InputField") value2 = ui.createWidget("Gui::InputField")
value2.setText(self.FORMAT % self.Height) value2.setText(self.FORMAT % self.Height)
grid.addWidget(label2,2,0,1,1) grid.addWidget(label2,2,0,1,1)
grid.addWidget(value2,2,1,1,1) grid.addWidget(value2,2,1,1,1)
label3 = QtGui.QLabel(translate("Arch","Alignment").decode("utf8")) label3 = QtGui.QLabel(translate("Arch","Alignment").decode("utf8"))
value3 = QtGui.QComboBox() value3 = QtGui.QComboBox()
items = ["Center","Left","Right"] items = ["Center","Left","Right"]
@ -307,7 +308,7 @@ class _CommandWall:
value3.setCurrentIndex(items.index(self.Align)) value3.setCurrentIndex(items.index(self.Align))
grid.addWidget(label3,3,0,1,1) grid.addWidget(label3,3,0,1,1)
grid.addWidget(value3,3,1,1,1) grid.addWidget(value3,3,1,1,1)
label4 = QtGui.QLabel(translate("Arch","Con&tinue").decode("utf8")) label4 = QtGui.QLabel(translate("Arch","Con&tinue").decode("utf8"))
value4 = QtGui.QCheckBox() value4 = QtGui.QCheckBox()
value4.setObjectName("ContinueCmd") value4.setObjectName("ContinueCmd")
@ -324,7 +325,7 @@ class _CommandWall:
QtCore.QObject.connect(value3,QtCore.SIGNAL("currentIndexChanged(int)"),self.setAlign) QtCore.QObject.connect(value3,QtCore.SIGNAL("currentIndexChanged(int)"),self.setAlign)
QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue) QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
return w return w
def setWidth(self,d): def setWidth(self,d):
self.Width = d self.Width = d
self.tracker.width(d) self.tracker.width(d)
@ -354,7 +355,7 @@ class _CommandMergeWalls:
def Activated(self): def Activated(self):
walls = FreeCADGui.Selection.getSelection() walls = FreeCADGui.Selection.getSelection()
if len(walls) == 1: if len(walls) == 1:
if Draft.getType(walls[0]) == "Wall": if Draft.getType(walls[0]) == "Wall":
ostr = "FreeCAD.ActiveDocument."+ walls[0].Name ostr = "FreeCAD.ActiveDocument."+ walls[0].Name
ok = False ok = False
@ -382,7 +383,7 @@ class _CommandMergeWalls:
FreeCADGui.addModule("Arch") FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.joinWalls(FreeCADGui.Selection.getSelection(),delete=True)") FreeCADGui.doCommand("Arch.joinWalls(FreeCADGui.Selection.getSelection(),delete=True)")
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
class _Wall(ArchComponent.Component): class _Wall(ArchComponent.Component):
"The Wall object" "The Wall object"
@ -398,10 +399,10 @@ class _Wall(ArchComponent.Component):
obj.Align = ['Left','Right','Center'] obj.Align = ['Left','Right','Center']
obj.Role = Roles obj.Role = Roles
self.Type = "Wall" self.Type = "Wall"
def execute(self,obj): def execute(self,obj):
"builds the wall shape" "builds the wall shape"
import Part, DraftGeomUtils import Part, DraftGeomUtils
pl = obj.Placement pl = obj.Placement
normal,length,width,height = self.getDefaultValues(obj) normal,length,width,height = self.getDefaultValues(obj)
@ -417,7 +418,7 @@ class _Wall(ArchComponent.Component):
if not obj.Base.Shape.Solids: if not obj.Base.Shape.Solids:
# let pass invalid objects if they have solids... # let pass invalid objects if they have solids...
return return
if hasattr(obj,"Face"): if hasattr(obj,"Face"):
if obj.Face > 0: if obj.Face > 0:
if len(obj.Base.Shape.Faces) >= obj.Face: if len(obj.Base.Shape.Faces) >= obj.Face:
@ -455,7 +456,7 @@ class _Wall(ArchComponent.Component):
else: else:
base = None base = None
FreeCAD.Console.PrintError(str(translate("Arch","Error: Invalid base object"))) FreeCAD.Console.PrintError(str(translate("Arch","Error: Invalid base object")))
elif obj.Base.isDerivedFrom("Mesh::Feature"): elif obj.Base.isDerivedFrom("Mesh::Feature"):
if obj.Base.Mesh.isSolid(): if obj.Base.Mesh.isSolid():
if obj.Base.Mesh.countComponents() == 1: if obj.Base.Mesh.countComponents() == 1:
@ -469,10 +470,10 @@ class _Wall(ArchComponent.Component):
# computing a shape from scratch # computing a shape from scratch
if length and width and height: if length and width and height:
base = Part.makeBox(length,width,height) base = Part.makeBox(length,width,height)
base = self.processSubShapes(obj,base,pl) base = self.processSubShapes(obj,base,pl)
self.applyShape(obj,base,pl) self.applyShape(obj,base,pl)
def onChanged(self,obj,prop): def onChanged(self,obj,prop):
self.hideSubobjects(obj,prop) self.hideSubobjects(obj,prop)
ArchComponent.Component.onChanged(self,obj,prop) ArchComponent.Component.onChanged(self,obj,prop)

View File

@ -43,7 +43,7 @@ WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane",
Roles = ["Window","Door"] Roles = ["Window","Door"]
def makeWindow(baseobj=None,width=None,height=None,parts=None,name=translate("Arch","Window")): def makeWindow(baseobj=None,width=None,height=None,parts=None,name="Window"):
'''makeWindow(baseobj,[width,height,parts,name]): creates a window based on the '''makeWindow(baseobj,[width,height,parts,name]): creates a window based on the
given base 2D object (sketch or draft).''' given base 2D object (sketch or draft).'''
@ -53,7 +53,7 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name=translate("Ar
return obj return obj
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
obj.Label = name obj.Label = translate("Arch",name)
_Window(obj) _Window(obj)
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
_ViewProviderWindow(obj.ViewObject) _ViewProviderWindow(obj.ViewObject)
@ -515,18 +515,18 @@ class _CommandWindow:
"sets up a taskbox widget" "sets up a taskbox widget"
w = QtGui.QWidget() w = QtGui.QWidget()
ui = FreeCADGui.UiLoader() ui = FreeCADGui.UiLoader()
w.setWindowTitle(translate("Arch","Window options")) w.setWindowTitle(translate("Arch","Window options").decode("utf8"))
grid = QtGui.QGridLayout(w) grid = QtGui.QGridLayout(w)
# sill height # sill height
labels = QtGui.QLabel(translate("Arch","Sill height")) labels = QtGui.QLabel(translate("Arch","Sill height").decode("utf8"))
values = ui.createWidget("Gui::InputField") values = ui.createWidget("Gui::InputField")
grid.addWidget(labels,0,0,1,1) grid.addWidget(labels,0,0,1,1)
grid.addWidget(values,0,1,1,1) grid.addWidget(values,0,1,1,1)
QtCore.QObject.connect(values,QtCore.SIGNAL("valueChanged(double)"),self.setSill) QtCore.QObject.connect(values,QtCore.SIGNAL("valueChanged(double)"),self.setSill)
# presets box # presets box
labelp = QtGui.QLabel(translate("Arch","Preset")) labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8"))
valuep = QtGui.QComboBox() valuep = QtGui.QComboBox()
valuep.addItems(["Create from scratch"]+WindowPresets) valuep.addItems(["Create from scratch"]+WindowPresets)
valuep.setCurrentIndex(self.Preset) valuep.setCurrentIndex(self.Preset)

View File

@ -2,8 +2,8 @@
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2009, 2010 * #* Copyright (c) 2009, 2010 *
#* Yorik van Havre <yorik@uncreated.net>, Ken Cline <cline@frii.com> * #* Yorik van Havre <yorik@uncreated.net>, Ken Cline <cline@frii.com> *
#* * #* *
#* This program is free software; you can redistribute it and/or modify * #* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * #* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -223,7 +223,7 @@ class DraftTool:
self.ui = None self.ui = None
self.call = None self.call = None
self.support = None self.support = None
self.point = None self.point = None
self.commitList = [] self.commitList = []
self.doc = FreeCAD.ActiveDocument self.doc = FreeCAD.ActiveDocument
if not self.doc: if not self.doc:
@ -303,7 +303,7 @@ class DraftTool:
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Helper tools # Helper tools
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
class SelectPlane(DraftTool): class SelectPlane(DraftTool):
"The Draft_SelectPlane FreeCAD command definition" "The Draft_SelectPlane FreeCAD command definition"
@ -688,7 +688,7 @@ class BezCurve(Line):
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_BezCurve", "Creates a Bezier curve. CTRL to snap, SHIFT to constrain")} 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_BezCurve", "Creates a Bezier curve. CTRL to snap, SHIFT to constrain")}
def Activated(self): def Activated(self):
Line.Activated(self,name=translate("draft","BezCurve")) Line.Activated(self,name=translate("draft","BezCurve").decode("utf8"))
if self.doc: if self.doc:
self.bezcurvetrack = bezcurveTracker() self.bezcurvetrack = bezcurveTracker()
@ -860,7 +860,7 @@ class Rectangle(Creator):
def finish(self,closed=False,cont=False): def finish(self,closed=False,cont=False):
"terminates the operation and closes the poly if asked" "terminates the operation and closes the poly if asked"
Creator.finish(self) Creator.finish(self)
if self.ui: if self.ui:
self.rect.off() self.rect.off()
self.rect.finalize() self.rect.finalize()
@ -1121,11 +1121,11 @@ class Arc(Creator):
self.linetrack.on() self.linetrack.on()
msg(translate("draft", "Pick radius:\n")) msg(translate("draft", "Pick radius:\n"))
if self.planetrack: if self.planetrack:
self.planetrack.set(self.point) self.planetrack.set(self.point)
elif (self.step == 1): # choose radius elif (self.step == 1): # choose radius
if self.closedCircle: if self.closedCircle:
self.drawArc() self.drawArc()
else: else:
self.ui.labelRadius.setText("Start angle") self.ui.labelRadius.setText("Start angle")
self.ui.radiusValue.setText(self.ui.AFORMAT % 0) self.ui.radiusValue.setText(self.ui.AFORMAT % 0)
self.linetrack.p1(self.center) self.linetrack.p1(self.center)
@ -1394,8 +1394,8 @@ class Polygon(Creator):
def drawPolygon(self): def drawPolygon(self):
"actually draws the FreeCAD object" "actually draws the FreeCAD object"
rot,sup,pts,fil = self.getStrings() rot,sup,pts,fil = self.getStrings()
if Draft.getParam("UsePartPrimitives",False): if Draft.getParam("UsePartPrimitives",False):
self.commit(translate("draft","Create Polygon"), self.commit(translate("draft","Create Polygon"),
['import Part', ['import Part',
'pl=FreeCAD.Placement()', 'pl=FreeCAD.Placement()',
@ -1468,7 +1468,7 @@ class Ellipse(Creator):
def finish(self,closed=False,cont=False): def finish(self,closed=False,cont=False):
"terminates the operation and closes the poly if asked" "terminates the operation and closes the poly if asked"
Creator.finish(self) Creator.finish(self)
if self.ui: if self.ui:
self.rect.off() self.rect.off()
self.rect.finalize() self.rect.finalize()
@ -1727,7 +1727,7 @@ class Dimension(Creator):
['Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')']) ['Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+','+str(self.link[2])+','+DraftVecUtils.toString(self.node[2])+')'])
elif self.arcmode: elif self.arcmode:
self.commit(translate("draft","Create Dimension"), self.commit(translate("draft","Create Dimension"),
['Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+',"'+str(self.arcmode)+'",'+DraftVecUtils.toString(self.node[2])+')']) ['Draft.makeDimension(FreeCAD.ActiveDocument.'+self.link[0].Name+','+str(self.link[1])+',"'+str(self.arcmode)+'",'+DraftVecUtils.toString(self.node[2])+')'])
else: else:
self.commit(translate("draft","Create Dimension"), self.commit(translate("draft","Create Dimension"),
['Draft.makeDimension('+DraftVecUtils.toString(self.node[0])+','+DraftVecUtils.toString(self.node[1])+','+DraftVecUtils.toString(self.node[2])+')']) ['Draft.makeDimension('+DraftVecUtils.toString(self.node[0])+','+DraftVecUtils.toString(self.node[1])+','+DraftVecUtils.toString(self.node[2])+')'])
@ -1742,7 +1742,7 @@ class Dimension(Creator):
self.dir = self.node[1].sub(self.node[0]) self.dir = self.node[1].sub(self.node[0])
self.node = [self.node[1]] self.node = [self.node[1]]
self.link = None self.link = None
def selectEdge(self): def selectEdge(self):
self.selectmode = not(self.selectmode) self.selectmode = not(self.selectmode)
@ -1888,8 +1888,8 @@ class Dimension(Creator):
self.link = [self.link[0],ob] self.link = [self.link[0],ob]
else: else:
msg(translate("draft", "Edges don't intersect!\n")) msg(translate("draft", "Edges don't intersect!\n"))
self.finish() self.finish()
return return
self.dimtrack.on() self.dimtrack.on()
else: else:
self.node.append(self.point) self.node.append(self.point)
@ -1963,18 +1963,18 @@ class ShapeString(Creator):
dquote = '"' dquote = '"'
if type(self.SString) == unicode: # Python3: no more unicode if type(self.SString) == unicode: # Python3: no more unicode
String = 'u' + dquote + self.SString.encode('unicode_escape') + dquote String = 'u' + dquote + self.SString.encode('unicode_escape') + dquote
else: else:
String = dquote + self.SString + dquote String = dquote + self.SString + dquote
Size = str(self.SSSize) # numbers are ascii so this should always work Size = str(self.SSSize) # numbers are ascii so this should always work
Tracking = str(self.SSTrack) # numbers are ascii so this should always work Tracking = str(self.SSTrack) # numbers are ascii so this should always work
FFile = dquote + self.FFile + dquote FFile = dquote + self.FFile + dquote
# print("debug: D_T ShapeString.createObject type(String): " str(type(String))) # print("debug: D_T ShapeString.createObject type(String): " str(type(String)))
# print("debug: D_T ShapeString.createObject type(FFile): " str(type(FFile))) # print("debug: D_T ShapeString.createObject type(FFile): " str(type(FFile)))
try: try:
qr,sup,points,fil = self.getStrings() qr,sup,points,fil = self.getStrings()
FreeCADGui.addModule("Draft") FreeCADGui.addModule("Draft")
self.commit(translate("draft","Create ShapeString"), self.commit(translate("draft","Create ShapeString"),
['ss=Draft.makeShapeString(String='+String+',FontFile='+FFile+',Size='+Size+',Tracking='+Tracking+')', ['ss=Draft.makeShapeString(String='+String+',FontFile='+FFile+',Size='+Size+',Tracking='+Tracking+')',
'plm=FreeCAD.Placement()', 'plm=FreeCAD.Placement()',
@ -2008,15 +2008,15 @@ class ShapeString(Creator):
self.ssBase = Vector(numx,numy,numz) self.ssBase = Vector(numx,numy,numz)
self.ui.SSUi() #move on to next step in parameter entry self.ui.SSUi() #move on to next step in parameter entry
def numericSSize(self,ssize): def numericSSize(self,ssize):
'''this function is called by the toolbar when valid size parameter '''this function is called by the toolbar when valid size parameter
has been entered. ''' has been entered. '''
self.SSSize = ssize self.SSSize = ssize
self.ui.STrackUi() self.ui.STrackUi()
def numericSTrack(self,strack): def numericSTrack(self,strack):
'''this function is called by the toolbar when valid size parameter '''this function is called by the toolbar when valid size parameter
has been entered. ?''' has been entered. ?'''
self.SSTrack = strack self.SSTrack = strack
self.ui.SFileUi() self.ui.SFileUi()
@ -2061,7 +2061,7 @@ class Move(Modifier):
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_Move", "Moves the selected objects between 2 points. CTRL to snap, SHIFT to constrain, ALT to copy")} 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_Move", "Moves the selected objects between 2 points. CTRL to snap, SHIFT to constrain, ALT to copy")}
def Activated(self): def Activated(self):
self.name = translate("draft","Move") self.name = translate("draft","Move").decode("utf8")
Modifier.Activated(self,self.name) Modifier.Activated(self,self.name)
self.ghost = None self.ghost = None
if self.ui: if self.ui:
@ -2211,7 +2211,7 @@ class ApplyStyle(Modifier):
if (ob.Type == "App::DocumentObjectGroup"): if (ob.Type == "App::DocumentObjectGroup"):
c.extend(self.formatGroup(ob)) c.extend(self.formatGroup(ob))
else: else:
c.append('Draft.formatObject(FreeCAD.ActiveDocument.'+ob.Name+')') c.append('Draft.formatObject(FreeCAD.ActiveDocument.'+ob.Name+')')
class Rotate(Modifier): class Rotate(Modifier):
"The Draft_Rotate FreeCAD command definition" "The Draft_Rotate FreeCAD command definition"
@ -2312,7 +2312,7 @@ class Rotate(Modifier):
if (currentrad != 0): if (currentrad != 0):
angle = DraftVecUtils.angle(plane.u, self.point.sub(self.center), plane.axis) angle = DraftVecUtils.angle(plane.u, self.point.sub(self.center), plane.axis)
else: angle = 0 else: angle = 0
if (angle < self.firstangle): if (angle < self.firstangle):
sweep = (2*math.pi-self.firstangle)+angle sweep = (2*math.pi-self.firstangle)+angle
else: else:
sweep = angle - self.firstangle sweep = angle - self.firstangle
@ -2355,7 +2355,7 @@ class Rotate(Modifier):
angle = self.point.sub(self.center).getAngle(plane.u) angle = self.point.sub(self.center).getAngle(plane.u)
if DraftVecUtils.project(self.point.sub(self.center), plane.v).getAngle(plane.v) > 1: if DraftVecUtils.project(self.point.sub(self.center), plane.v).getAngle(plane.v) > 1:
angle = -angle angle = -angle
if (angle < self.firstangle): if (angle < self.firstangle):
sweep = (2*math.pi-self.firstangle)+angle sweep = (2*math.pi-self.firstangle)+angle
else: else:
sweep = angle - self.firstangle sweep = angle - self.firstangle
@ -2595,7 +2595,7 @@ class Upgrade(Modifier):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
if FreeCADGui.Selection.getSelection(): if FreeCADGui.Selection.getSelection():
FreeCADGui.addModule("Draft") FreeCADGui.addModule("Draft")
@ -2624,7 +2624,7 @@ class Downgrade(Modifier):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
if FreeCADGui.Selection.getSelection(): if FreeCADGui.Selection.getSelection():
FreeCADGui.addModule("Draft") FreeCADGui.addModule("Draft")
@ -2697,7 +2697,7 @@ class Trimex(Modifier):
self.edges = self.obj.Shape.Wires[0].Edges self.edges = self.obj.Shape.Wires[0].Edges
self.edges = DraftGeomUtils.sortEdges(self.edges) self.edges = DraftGeomUtils.sortEdges(self.edges)
else: else:
self.edges = self.obj.Shape.Edges self.edges = self.obj.Shape.Edges
self.ghost = [] self.ghost = []
lc = self.obj.ViewObject.LineColor lc = self.obj.ViewObject.LineColor
sc = (lc[0],lc[1],lc[2]) sc = (lc[0],lc[1],lc[2])
@ -2856,9 +2856,9 @@ class Trimex(Modifier):
ghost.on() ghost.on()
# resetting the visible edges # resetting the visible edges
if not reverse: if not reverse:
li = list(range(npoint+1,len(self.edges))) li = list(range(npoint+1,len(self.edges)))
else: else:
li = list(range(npoint-1,-1,-1)) li = list(range(npoint-1,-1,-1))
for i in li: for i in li:
edge = self.edges[i] edge = self.edges[i]
@ -2896,21 +2896,21 @@ class Trimex(Modifier):
self.doc.openTransaction("Trim/extend") self.doc.openTransaction("Trim/extend")
if Draft.getType(self.obj) in ["Wire","BSpline"]: if Draft.getType(self.obj) in ["Wire","BSpline"]:
p = [] p = []
if self.placement: if self.placement:
invpl = self.placement.inverse() invpl = self.placement.inverse()
for v in newshape.Vertexes: for v in newshape.Vertexes:
np = v.Point np = v.Point
if self.placement: if self.placement:
np = invpl.multVec(np) np = invpl.multVec(np)
p.append(np) p.append(np)
self.obj.Points = p self.obj.Points = p
elif Draft.getType(self.obj) == "Part::Line": elif Draft.getType(self.obj) == "Part::Line":
p = [] p = []
if self.placement: if self.placement:
invpl = self.placement.inverse() invpl = self.placement.inverse()
for v in newshape.Vertexes: for v in newshape.Vertexes:
np = v.Point np = v.Point
if self.placement: if self.placement:
np = invpl.multVec(np) np = invpl.multVec(np)
p.append(np) p.append(np)
if ((p[0].x == self.obj.X1) and (p[0].y == self.obj.Y1) and (p[0].z == self.obj.Z1)): if ((p[0].x == self.obj.X1) and (p[0].y == self.obj.Y1) and (p[0].z == self.obj.Z1)):
@ -2972,7 +2972,7 @@ class Scale(Modifier):
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_Scale", "Scales the selected objects from a base point. CTRL to snap, SHIFT to constrain, ALT to copy")} 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_Scale", "Scales the selected objects from a base point. CTRL to snap, SHIFT to constrain, ALT to copy")}
def Activated(self): def Activated(self):
self.name = translate("draft","Scale") self.name = translate("draft","Scale").decode("utf8")
Modifier.Activated(self,self.name) Modifier.Activated(self,self.name)
self.ghost = None self.ghost = None
if self.ui: if self.ui:
@ -3134,7 +3134,7 @@ class Drawing(Modifier):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
sel = FreeCADGui.Selection.getSelection() sel = FreeCADGui.Selection.getSelection()
if not sel: if not sel:
@ -3161,14 +3161,14 @@ class Drawing(Modifier):
if obj.isDerivedFrom("Drawing::FeatureView"): if obj.isDerivedFrom("Drawing::FeatureView"):
otherProjection = obj otherProjection = obj
break break
sel.reverse() sel.reverse()
for obj in sel: for obj in sel:
if ( obj.ViewObject.isVisible() and not obj.isDerivedFrom("Drawing::FeatureView") if ( obj.ViewObject.isVisible() and not obj.isDerivedFrom("Drawing::FeatureView")
and not obj.isDerivedFrom("Drawing::FeaturePage") ): and not obj.isDerivedFrom("Drawing::FeaturePage") ):
name = 'View'+obj.Name name = 'View'+obj.Name
# no reason to remove the old one... # no reason to remove the old one...
#oldobj = self.page.getObject(name) #oldobj = self.page.getObject(name)
#if oldobj: #if oldobj:
# self.doc.removeObject(oldobj.Name) # self.doc.removeObject(oldobj.Name)
Draft.makeDrawingView(obj,self.page,otherProjection=otherProjection) Draft.makeDrawingView(obj,self.page,otherProjection=otherProjection)
self.doc.recompute() self.doc.recompute()
@ -3240,7 +3240,7 @@ class Edit(Modifier):
self.call = self.view.addEventCallback("SoEvent",selectObject) self.call = self.view.addEventCallback("SoEvent",selectObject)
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
if self.doc: if self.doc:
self.obj = FreeCADGui.Selection.getSelection() self.obj = FreeCADGui.Selection.getSelection()
@ -3293,10 +3293,10 @@ class Edit(Modifier):
self.editpoints.append(self.obj.Shape.Vertexes[2].Point) self.editpoints.append(self.obj.Shape.Vertexes[2].Point)
v = self.obj.Shape.Vertexes v = self.obj.Shape.Vertexes
self.bx = v[1].Point.sub(v[0].Point) self.bx = v[1].Point.sub(v[0].Point)
if self.obj.Length < 0: if self.obj.Length < 0:
self.bx = self.bx.negative() self.bx = self.bx.negative()
self.by = v[2].Point.sub(v[1].Point) self.by = v[2].Point.sub(v[1].Point)
if self.obj.Height < 0: if self.obj.Height < 0:
self.by = self.by.negative() self.by = self.by.negative()
elif Draft.getType(self.obj) == "Polygon": elif Draft.getType(self.obj) == "Polygon":
self.editpoints.append(self.obj.Placement.Base) self.editpoints.append(self.obj.Placement.Base)
@ -3383,15 +3383,15 @@ class Edit(Modifier):
if 'EditNode' in info["Component"]: if 'EditNode' in info["Component"]:
self.delPoint(int(info["Component"][8:])) self.delPoint(int(info["Component"][8:]))
# don't do tan/sym on DWire/BSpline! # don't do tan/sym on DWire/BSpline!
elif ((Draft.getType(self.obj) == "BezCurve") and elif ((Draft.getType(self.obj) == "BezCurve") and
(self.ui.sharpButton.isChecked())): (self.ui.sharpButton.isChecked())):
if 'EditNode' in info["Component"]: if 'EditNode' in info["Component"]:
self.smoothBezPoint(int(info["Component"][8:]), info, 'Sharp') self.smoothBezPoint(int(info["Component"][8:]), info, 'Sharp')
elif ((Draft.getType(self.obj) == "BezCurve") and elif ((Draft.getType(self.obj) == "BezCurve") and
(self.ui.tangentButton.isChecked())): (self.ui.tangentButton.isChecked())):
if 'EditNode' in info["Component"]: if 'EditNode' in info["Component"]:
self.smoothBezPoint(int(info["Component"][8:]), info, 'Tangent') self.smoothBezPoint(int(info["Component"][8:]), info, 'Tangent')
elif ((Draft.getType(self.obj) == "BezCurve") and elif ((Draft.getType(self.obj) == "BezCurve") and
(self.ui.symmetricButton.isChecked())): (self.ui.symmetricButton.isChecked())):
if 'EditNode' in info["Component"]: if 'EditNode' in info["Component"]:
self.smoothBezPoint(int(info["Component"][8:]), info, 'Symmetric') self.smoothBezPoint(int(info["Component"][8:]), info, 'Symmetric')
@ -3521,7 +3521,7 @@ class Edit(Modifier):
elif self.editing == 2: elif self.editing == 2:
self.obj.Dimline = v self.obj.Dimline = v
elif self.editing == 3: elif self.editing == 3:
self.obj.ViewObject.TextPosition = v self.obj.ViewObject.TextPosition = v
elif Draft.getType(self.obj) == "Space": elif Draft.getType(self.obj) == "Space":
if self.editing == 0: if self.editing == 0:
self.obj.ViewObject.TextPosition = v self.obj.ViewObject.TextPosition = v
@ -3603,7 +3603,7 @@ class Edit(Modifier):
if ( uNewPoint > uPoints[i] ) and ( uNewPoint < uPoints[i+1] ): if ( uNewPoint > uPoints[i] ) and ( uNewPoint < uPoints[i+1] ):
pts.insert(i+1, self.invpl.multVec(point)) pts.insert(i+1, self.invpl.multVec(point))
break break
# DNC: fix: add points to last segment if curve is closed # DNC: fix: add points to last segment if curve is closed
if ( self.obj.Closed ) and ( uNewPoint > uPoints[-1] ) : if ( self.obj.Closed ) and ( uNewPoint > uPoints[-1] ) :
pts.append(self.invpl.multVec(point)) pts.append(self.invpl.multVec(point))
self.doc.openTransaction("Edit "+self.obj.Name) self.doc.openTransaction("Edit "+self.obj.Name)
@ -3615,7 +3615,7 @@ class Edit(Modifier):
if not (Draft.getType(self.obj) in ["Wire","BSpline","BezCurve"]): return if not (Draft.getType(self.obj) in ["Wire","BSpline","BezCurve"]): return
if len(self.obj.Points) <= 2: if len(self.obj.Points) <= 2:
msg(translate("draft", "Active object must have more than two points/nodes\n"),'warning') msg(translate("draft", "Active object must have more than two points/nodes\n"),'warning')
else: else:
pts = self.obj.Points pts = self.obj.Points
pts.pop(point) pts.pop(point)
self.doc.openTransaction("Edit "+self.obj.Name) self.doc.openTransaction("Edit "+self.obj.Name)
@ -3707,7 +3707,7 @@ class Edit(Modifier):
self.obj.Continuity=newcont self.obj.Continuity=newcont
self.doc.commitTransaction() self.doc.commitTransaction()
self.resetTrackers() self.resetTrackers()
def resetTrackersBezier(self): def resetTrackersBezier(self):
knotmarkers = (coin.SoMarkerSet.DIAMOND_FILLED_9_9,#sharp knotmarkers = (coin.SoMarkerSet.DIAMOND_FILLED_9_9,#sharp
coin.SoMarkerSet.SQUARE_FILLED_9_9, #tangent coin.SoMarkerSet.SQUARE_FILLED_9_9, #tangent
@ -3934,7 +3934,7 @@ class Shape2DView(Modifier):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
faces = [] faces = []
objs = [] objs = []
@ -3973,7 +3973,7 @@ class Draft2Sketch(Modifier):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
sel = FreeCADGui.Selection.getSelection() sel = FreeCADGui.Selection.getSelection()
allSketches = True allSketches = True
@ -3990,11 +3990,11 @@ class Draft2Sketch(Modifier):
if not sel: if not sel:
return return
elif allDraft: elif allDraft:
lines = ["Draft.makeSketch(FreeCADGui.Selection.getSelection(),autoconstraints=True)"] lines = ["Draft.makeSketch(FreeCADGui.Selection.getSelection(),autoconstraints=True)"]
self.commit(translate("draft","Convert to Sketch"), self.commit(translate("draft","Convert to Sketch"),
lines + ['FreeCAD.ActiveDocument.recompute()']) lines + ['FreeCAD.ActiveDocument.recompute()'])
elif allSketches: elif allSketches:
lines = ["Draft.draftify(FreeCAD.ActiveDocument."+o.Name+",delete=False)" for o in sel] lines = ["Draft.draftify(FreeCAD.ActiveDocument."+o.Name+",delete=False)" for o in sel]
self.commit(translate("draft","Convert to Draft"), self.commit(translate("draft","Convert to Draft"),
lines + ['FreeCAD.ActiveDocument.recompute()']) lines + ['FreeCAD.ActiveDocument.recompute()'])
else: else:
@ -4006,7 +4006,7 @@ class Draft2Sketch(Modifier):
lines.append("Draft.makeSketch(FreeCAD.ActiveDocument."+obj.Name+",autoconstraints=True)") lines.append("Draft.makeSketch(FreeCAD.ActiveDocument."+obj.Name+",autoconstraints=True)")
elif obj.isDerivedFrom("Part::Feature"): elif obj.isDerivedFrom("Part::Feature"):
if (len(obj.Shape.Wires) == 1) or (len(obj.Shape.Edges) == 1): if (len(obj.Shape.Wires) == 1) or (len(obj.Shape.Edges) == 1):
lines.append("Draft.makeSketch(FreeCAD.ActiveDocument."+obj.Name+",autoconstraints=False)") lines.append("Draft.makeSketch(FreeCAD.ActiveDocument."+obj.Name+",autoconstraints=False)")
self.commit(translate("draft","Convert"), self.commit(translate("draft","Convert"),
lines + ['FreeCAD.ActiveDocument.recompute()']) lines + ['FreeCAD.ActiveDocument.recompute()'])
self.finish() self.finish()
@ -4031,7 +4031,7 @@ class Array(Modifier):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
if FreeCADGui.Selection.getSelection(): if FreeCADGui.Selection.getSelection():
obj = FreeCADGui.Selection.getSelection()[0] obj = FreeCADGui.Selection.getSelection()[0]
@ -4061,7 +4061,7 @@ class PathArray(Modifier):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
sel = FreeCADGui.Selection.getSelectionEx() sel = FreeCADGui.Selection.getSelectionEx()
if sel: if sel:
@ -4131,7 +4131,7 @@ class Point(Creator):
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(),self.callbackMove) self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(),self.callbackMove)
commitlist = [] commitlist = []
if Draft.getParam("UsePartPrimitives",False): if Draft.getParam("UsePartPrimitives",False):
# using # using
commitlist.append((translate("draft","Create Point"), commitlist.append((translate("draft","Create Point"),
['point = FreeCAD.ActiveDocument.addObject("Part::Vertex","Point")', ['point = FreeCAD.ActiveDocument.addObject("Part::Vertex","Point")',
'point.X = '+str(self.stack[0][0]), 'point.X = '+str(self.stack[0][0]),
@ -4185,7 +4185,7 @@ class Draft_Clone(Modifier):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
if FreeCADGui.Selection.getSelection(): if FreeCADGui.Selection.getSelection():
FreeCAD.ActiveDocument.openTransaction("Clone") FreeCAD.ActiveDocument.openTransaction("Clone")
@ -4256,7 +4256,7 @@ class Draft_Facebinder(Creator):
self.proceed() self.proceed()
def proceed(self): def proceed(self):
if self.call: if self.call:
self.view.removeEventCallback("SoEvent",self.call) self.view.removeEventCallback("SoEvent",self.call)
if FreeCADGui.Selection.getSelection(): if FreeCADGui.Selection.getSelection():
FreeCAD.ActiveDocument.openTransaction("Facebinder") FreeCAD.ActiveDocument.openTransaction("Facebinder")
@ -4548,5 +4548,3 @@ FreeCADGui.addCommand('Draft_Snap_WorkingPlane',Draft_Snap_WorkingPlane())
# a global place to look for active draft Command # a global place to look for active draft Command
FreeCAD.activeDraftCommand = None FreeCAD.activeDraftCommand = None