Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code
This commit is contained in:
commit
71efef4761
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -36,10 +36,11 @@ __title__="FreeCAD Axis System"
|
|||
__author__ = "Yorik van Havre"
|
||||
__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
|
||||
based on the given number of axes and interval distances'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Axis(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderAxis(obj.ViewObject)
|
||||
|
@ -61,7 +62,7 @@ class _CommandAxis:
|
|||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Axis","Axis"),
|
||||
'Accel': "A, X",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Axis","Creates an axis system.")}
|
||||
|
||||
|
||||
def Activated(self):
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Axis"))
|
||||
FreeCADGui.addModule("Arch")
|
||||
|
@ -76,7 +77,7 @@ class _CommandAxis:
|
|||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
|
||||
class _Axis:
|
||||
"The Axis object"
|
||||
def __init__(self,obj):
|
||||
|
@ -88,7 +89,7 @@ class _Axis:
|
|||
self.Type = "Axis"
|
||||
obj.Length=3000
|
||||
obj.Proxy = self
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
import Part
|
||||
geoms = []
|
||||
|
@ -109,7 +110,7 @@ class _Axis:
|
|||
sh = Part.Compound(geoms)
|
||||
sh.Placement = obj.Placement
|
||||
obj.Shape = sh
|
||||
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
if prop in ["Angles","Distances","Placement"]:
|
||||
self.execute(obj)
|
||||
|
@ -120,7 +121,7 @@ class _Axis:
|
|||
def __setstate__(self,state):
|
||||
if state:
|
||||
self.Type = state
|
||||
|
||||
|
||||
class _ViewProviderAxis:
|
||||
"A View Provider for the Axis object"
|
||||
|
||||
|
@ -138,7 +139,7 @@ class _ViewProviderAxis:
|
|||
vobj.LineColor = (0.13,0.15,0.37)
|
||||
vobj.DrawStyle = "Dashdot"
|
||||
vobj.NumberingStyle = "1,2,3"
|
||||
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Axis_Tree.svg"
|
||||
|
@ -162,7 +163,7 @@ class _ViewProviderAxis:
|
|||
sep.addChild(self.bubbleset)
|
||||
vobj.addDisplayMode(sep,"Default")
|
||||
self.onChanged(vobj,"BubbleSize")
|
||||
|
||||
|
||||
def getDisplayModes(self,vobj):
|
||||
return ["Default"]
|
||||
|
||||
|
@ -309,15 +310,15 @@ class _ViewProviderAxis:
|
|||
elif vobj.NumberingStyle == "L0,L1,L2":
|
||||
t.string = "L"+str(num)
|
||||
num += 1
|
||||
|
||||
|
||||
|
||||
|
||||
def setEdit(self,vobj,mode=0):
|
||||
taskd = _AxisTaskPanel()
|
||||
taskd.obj = vobj.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
|
@ -338,9 +339,9 @@ class _AxisTaskPanel:
|
|||
# the panel has a tree widget that contains categories
|
||||
# for the subcomponents, such as additions, subtractions.
|
||||
# the categories are shown only if they are not empty.
|
||||
|
||||
|
||||
self.updating = False
|
||||
|
||||
|
||||
self.obj = None
|
||||
self.form = QtGui.QWidget()
|
||||
self.form.setObjectName("TaskPanel")
|
||||
|
@ -356,8 +357,8 @@ class _AxisTaskPanel:
|
|||
self.tree.header().resizeSection(0,50)
|
||||
self.tree.header().resizeSection(1,80)
|
||||
self.tree.header().resizeSection(2,60)
|
||||
|
||||
# buttons
|
||||
|
||||
# buttons
|
||||
self.addButton = QtGui.QPushButton(self.form)
|
||||
self.addButton.setObjectName("addButton")
|
||||
self.addButton.setIcon(QtGui.QIcon(":/icons/Arch_Add.svg"))
|
||||
|
@ -383,7 +384,7 @@ class _AxisTaskPanel:
|
|||
|
||||
def getStandardButtons(self):
|
||||
return int(QtGui.QDialogButtonBox.Close)
|
||||
|
||||
|
||||
def update(self):
|
||||
'fills the treewidget'
|
||||
self.updating = True
|
||||
|
@ -398,7 +399,7 @@ class _AxisTaskPanel:
|
|||
item.setTextAlignment(0,QtCore.Qt.AlignLeft)
|
||||
self.retranslateUi(self.form)
|
||||
self.updating = False
|
||||
|
||||
|
||||
def addElement(self):
|
||||
item = QtGui.QTreeWidgetItem(self.tree)
|
||||
item.setText(0,str(self.tree.topLevelItemCount()))
|
||||
|
@ -413,7 +414,7 @@ class _AxisTaskPanel:
|
|||
nr = int(it.text(0))-1
|
||||
self.resetObject(remove=nr)
|
||||
self.update()
|
||||
|
||||
|
||||
def edit(self,item,column):
|
||||
if not self.updating:
|
||||
self.resetObject()
|
||||
|
@ -431,12 +432,12 @@ class _AxisTaskPanel:
|
|||
self.obj.Angles = a
|
||||
self.obj.touch()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
def reject(self):
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
|
||||
def retranslateUi(self, TaskPanel):
|
||||
TaskPanel.setWindowTitle(QtGui.QApplication.translate("Arch", "Axes", 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),
|
||||
QtGui.QApplication.translate("Arch", "Distance", None, QtGui.QApplication.UnicodeUTF8),
|
||||
QtGui.QApplication.translate("Arch", "Angle", None, QtGui.QApplication.UnicodeUTF8)])
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Arch_Axis',_CommandAxis())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -34,7 +34,7 @@ __title__="FreeCAD Building"
|
|||
__author__ = "Yorik van Havre"
|
||||
__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
|
||||
objects from the given list.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
|
@ -43,6 +43,7 @@ def makeBuilding(objectslist=None,baseobj=None,name=translate("Arch","Building")
|
|||
_ViewProviderBuilding(obj.ViewObject)
|
||||
if objectslist:
|
||||
obj.Group = objectslist
|
||||
obj.Label = translate("Arch",name)
|
||||
return obj
|
||||
|
||||
class _CommandBuilding:
|
||||
|
@ -55,7 +56,7 @@ class _CommandBuilding:
|
|||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
|
||||
def Activated(self):
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
ok = False
|
||||
|
@ -81,18 +82,18 @@ class _CommandBuilding:
|
|||
FreeCADGui.doCommand("Arch.makeBuilding("+ss+")")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
class _Building(ArchFloor._Floor):
|
||||
"The Building object"
|
||||
def __init__(self,obj):
|
||||
ArchFloor._Floor.__init__(self,obj)
|
||||
self.Type = "Building"
|
||||
obj.setEditorMode('Height',2)
|
||||
|
||||
|
||||
class _ViewProviderBuilding(ArchFloor._ViewProviderFloor):
|
||||
"A View Provider for the Building object"
|
||||
def __init__(self,vobj):
|
||||
ArchFloor._ViewProviderFloor.__init__(self,vobj)
|
||||
ArchFloor._ViewProviderFloor.__init__(self,vobj)
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2014 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2014 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -41,7 +41,7 @@ else:
|
|||
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"
|
||||
if type:
|
||||
if type == "Part":
|
||||
|
@ -62,7 +62,7 @@ def makeEquipment(baseobj=None,placement=None,name=translate("Arch","Equipment")
|
|||
else:
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Equipment(obj)
|
||||
obj.Label = name
|
||||
obj.Label = translate("Arch",name)
|
||||
if placement:
|
||||
obj.Placement = placement
|
||||
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
|
||||
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."""
|
||||
|
||||
|
||||
import Mesh, math, Part, DraftGeomUtils
|
||||
if not obj.isDerivedFrom("Mesh::Feature"):
|
||||
return
|
||||
mesh = obj.Mesh
|
||||
|
||||
|
||||
# 1. Flattening the mesh
|
||||
proj = []
|
||||
for f in mesh.Facets:
|
||||
|
@ -95,16 +95,16 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
|
|||
nf.append(p)
|
||||
proj.append(nf)
|
||||
flatmesh = Mesh.Mesh(proj)
|
||||
|
||||
|
||||
# 2. Removing wrong faces
|
||||
facets = []
|
||||
for f in flatmesh.Facets:
|
||||
if f.Normal.getAngle(direction) < math.pi:
|
||||
facets.append(f)
|
||||
cleanmesh = Mesh.Mesh(facets)
|
||||
|
||||
|
||||
#Mesh.show(cleanmesh)
|
||||
|
||||
|
||||
# 3. Getting the bigger mesh from the planar segments
|
||||
if largestonly:
|
||||
c = cleanmesh.getSeparateComponents()
|
||||
|
@ -122,9 +122,9 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
|
|||
a = m.Area
|
||||
#Mesh.show(boundarymesh)
|
||||
cleanmesh = boundarymesh
|
||||
|
||||
|
||||
# 4. Creating a Part and getting the contour
|
||||
|
||||
|
||||
shape = None
|
||||
for f in cleanmesh.Facets:
|
||||
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()
|
||||
|
||||
# 5. Extracting the largest wire
|
||||
|
||||
|
||||
if outeronly:
|
||||
count = 0
|
||||
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."
|
||||
else:
|
||||
shape = f
|
||||
|
||||
|
||||
return shape
|
||||
|
||||
|
||||
|
||||
class _CommandEquipment:
|
||||
"the Arch Equipment command definition"
|
||||
def GetResources(self):
|
||||
|
@ -169,8 +169,8 @@ class _CommandEquipment:
|
|||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
def Activated(self):
|
||||
|
||||
def Activated(self):
|
||||
s = FreeCADGui.Selection.getSelection()
|
||||
if not s:
|
||||
FreeCAD.Console.PrintError(translate("Arch","You must select a base object first!"))
|
||||
|
@ -185,8 +185,8 @@ class _CommandEquipment:
|
|||
if hasattr(s[0].ViewObject,"DiffuseColor"):
|
||||
FreeCADGui.doCommand("FreeCAD.ActiveDocument.Objects[-1].ViewObject.DiffuseColor = FreeCAD.ActiveDocument." + base + ".ViewObject.DiffuseColor")
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
class _Command3Views:
|
||||
"the Arch 3Views command definition"
|
||||
def GetResources(self):
|
||||
|
@ -196,8 +196,8 @@ class _Command3Views:
|
|||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
def Activated(self):
|
||||
|
||||
def Activated(self):
|
||||
s = FreeCADGui.Selection.getSelection()
|
||||
if len(s) != 1:
|
||||
FreeCAD.Console.PrintError(translate("Arch","You must select exactly one base object"))
|
||||
|
@ -243,10 +243,10 @@ class _Equipment(ArchComponent.Component):
|
|||
self.Type = "Equipment"
|
||||
obj.Role = Roles
|
||||
obj.Proxy = self
|
||||
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
self.hideSubobjects(obj,prop)
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
pl = obj.Placement
|
||||
if obj.Base:
|
||||
|
@ -258,7 +258,7 @@ class _Equipment(ArchComponent.Component):
|
|||
if base:
|
||||
import Mesh
|
||||
m = Mesh.Mesh(base.tessellate(1))
|
||||
|
||||
|
||||
elif obj.Base.isDerivedFrom("Mesh::Feature"):
|
||||
m = obj.Base.Mesh.copy()
|
||||
if m:
|
||||
|
@ -288,7 +288,7 @@ class _ViewProviderEquipment(ArchComponent.ViewProviderComponent):
|
|||
def getIcon(self):
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Equipment_Tree.svg"
|
||||
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Arch_Equipment',_CommandEquipment())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -34,11 +34,11 @@ __title__="FreeCAD Arch Floor"
|
|||
__author__ = "Yorik van Havre"
|
||||
__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
|
||||
objects from the given list.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
obj.Label = name
|
||||
obj.Label = translate("Arch",name)
|
||||
_Floor(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderFloor(obj.ViewObject)
|
||||
|
@ -56,7 +56,7 @@ class _CommandFloor:
|
|||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
|
||||
def Activated(self):
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
ok = False
|
||||
|
@ -81,7 +81,7 @@ class _CommandFloor:
|
|||
FreeCADGui.doCommand("Arch.makeFloor("+ss+")")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
class _Floor:
|
||||
"The Floor object"
|
||||
def __init__(self,obj):
|
||||
|
@ -118,21 +118,21 @@ class _Floor:
|
|||
if Draft.getType(o) in ["Wall","Structure"]:
|
||||
if not o.Height.Value:
|
||||
o.Proxy.execute(o)
|
||||
|
||||
|
||||
def addObject(self,child):
|
||||
if hasattr(self,"Object"):
|
||||
g = self.Object.Group
|
||||
if not child in g:
|
||||
g.append(child)
|
||||
self.Object.Group = g
|
||||
|
||||
|
||||
def removeObject(self,child):
|
||||
if hasattr(self,"Object"):
|
||||
g = self.Object.Group
|
||||
if child in g:
|
||||
g.remove(child)
|
||||
self.Object.Group = g
|
||||
|
||||
|
||||
class _ViewProviderFloor:
|
||||
"A View Provider for the Floor object"
|
||||
def __init__(self,vobj):
|
||||
|
@ -144,8 +144,8 @@ class _ViewProviderFloor:
|
|||
|
||||
def attach(self,vobj):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
def claimChildren(self):
|
||||
return self.Object.Group
|
||||
|
||||
|
@ -155,5 +155,5 @@ class _ViewProviderFloor:
|
|||
def __setstate__(self,state):
|
||||
return None
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Arch_Floor',_CommandFloor())
|
||||
|
|
|
@ -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
|
||||
containing wires) and a profile object (an extrudable 2D object containing faces or closed wires)"""
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Frame(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderFrame(obj.ViewObject)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* 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]]
|
||||
|
||||
|
||||
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
|
||||
panel element based on the given profile object and the given
|
||||
extrusion thickness. If no base object is given, you can also specify
|
||||
length and width for a simple cubic object.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Panel(obj)
|
||||
_ViewProviderPanel(obj.ViewObject)
|
||||
if baseobj:
|
||||
|
@ -94,7 +95,7 @@ class _CommandPanel:
|
|||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
def Activated(self):
|
||||
def Activated(self):
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
self.Length = p.GetFloat("PanelLength",1000)
|
||||
self.Width = p.GetFloat("PanelWidth",1000)
|
||||
|
@ -128,7 +129,7 @@ class _CommandPanel:
|
|||
self.tracker.length(self.Length)
|
||||
self.tracker.on()
|
||||
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox())
|
||||
|
||||
|
||||
def getPoint(self,point=None,obj=None):
|
||||
"this function is called by the snapper when it has a 3D point"
|
||||
self.tracker.finalize()
|
||||
|
@ -157,7 +158,7 @@ class _CommandPanel:
|
|||
ui = FreeCADGui.UiLoader()
|
||||
w.setWindowTitle(translate("Arch","Panel options").decode("utf8"))
|
||||
grid = QtGui.QGridLayout(w)
|
||||
|
||||
|
||||
# presets box
|
||||
labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8"))
|
||||
valuep = QtGui.QComboBox()
|
||||
|
@ -167,14 +168,14 @@ class _CommandPanel:
|
|||
valuep.addItems(fpresets)
|
||||
grid.addWidget(labelp,0,0,1,1)
|
||||
grid.addWidget(valuep,0,1,1,1)
|
||||
|
||||
|
||||
# length
|
||||
label1 = QtGui.QLabel(translate("Arch","Length").decode("utf8"))
|
||||
self.vLength = ui.createWidget("Gui::InputField")
|
||||
self.vLength.setText(self.FORMAT % self.Length)
|
||||
grid.addWidget(label1,1,0,1,1)
|
||||
grid.addWidget(self.vLength,1,1,1,1)
|
||||
|
||||
|
||||
# width
|
||||
label2 = QtGui.QLabel(translate("Arch","Width").decode("utf8"))
|
||||
self.vWidth = ui.createWidget("Gui::InputField")
|
||||
|
@ -188,7 +189,7 @@ class _CommandPanel:
|
|||
self.vHeight.setText(self.FORMAT % self.Thickness)
|
||||
grid.addWidget(label3,3,0,1,1)
|
||||
grid.addWidget(self.vHeight,3,1,1,1)
|
||||
|
||||
|
||||
# horizontal button
|
||||
value5 = QtGui.QPushButton(translate("Arch","Rotate").decode("utf8"))
|
||||
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(value5,QtCore.SIGNAL("pressed()"),self.rotate)
|
||||
return w
|
||||
|
||||
|
||||
def update(self,point,info):
|
||||
"this function is called by the Snapper when the mouse is moved"
|
||||
if FreeCADGui.Control.activeDialog():
|
||||
|
@ -225,7 +226,7 @@ class _CommandPanel:
|
|||
self.tracker.width(self.Width)
|
||||
self.tracker.height(self.Thickness)
|
||||
self.tracker.length(self.Length)
|
||||
|
||||
|
||||
def setWidth(self,d):
|
||||
self.Width = d
|
||||
|
||||
|
@ -239,13 +240,13 @@ class _CommandPanel:
|
|||
self.continueCmd = bool(i)
|
||||
if hasattr(FreeCADGui,"draftToolBar"):
|
||||
FreeCADGui.draftToolBar.continueMode = bool(i)
|
||||
|
||||
|
||||
def setPreset(self,i):
|
||||
if i > 0:
|
||||
self.vLength.setText(self.FORMAT % float(Presets[i][1]))
|
||||
self.vWidth.setText(self.FORMAT % float(Presets[i][2]))
|
||||
self.vHeight.setText(self.FORMAT % float(Presets[i][3]))
|
||||
|
||||
|
||||
def rotate(self):
|
||||
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.Sheets = 1
|
||||
self.Type = "Panel"
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
"creates the panel shape"
|
||||
|
||||
|
||||
import Part, DraftGeomUtils
|
||||
|
||||
|
||||
# base tests
|
||||
if obj.Base:
|
||||
if obj.Base.isDerivedFrom("Part::Feature"):
|
||||
|
@ -291,7 +292,7 @@ class _Panel(ArchComponent.Component):
|
|||
return
|
||||
elif obj.Base.isDerivedFrom("Part::Feature"):
|
||||
if not obj.Base.Solids:
|
||||
return
|
||||
return
|
||||
|
||||
# creating base shape
|
||||
pl = obj.Placement
|
||||
|
@ -317,7 +318,7 @@ class _Panel(ArchComponent.Component):
|
|||
base = ArchCommands.makeFace(base.Wires)
|
||||
self.BaseProfile = base
|
||||
self.ExtrusionVector = normal
|
||||
base = base.extrude(normal)
|
||||
base = base.extrude(normal)
|
||||
elif obj.Base.isDerivedFrom("Mesh::Feature"):
|
||||
if obj.Base.Mesh.isSolid():
|
||||
if obj.Base.Mesh.countComponents() == 1:
|
||||
|
@ -346,7 +347,7 @@ class _Panel(ArchComponent.Component):
|
|||
b.translate(n)
|
||||
bases.append(b)
|
||||
base = Part.makeCompound(bases)
|
||||
|
||||
|
||||
if base and normal and hasattr(obj,"Offset"):
|
||||
if obj.Offset.Value:
|
||||
v = DraftVecUtils.scaleTo(normal,obj.Offset.Value)
|
||||
|
@ -354,7 +355,7 @@ class _Panel(ArchComponent.Component):
|
|||
|
||||
# process subshapes
|
||||
base = self.processSubShapes(obj,base,pl)
|
||||
|
||||
|
||||
# applying
|
||||
if base:
|
||||
if not base.isNull():
|
||||
|
@ -437,7 +438,7 @@ class _PanelView:
|
|||
result += svg2
|
||||
result += '</g>'
|
||||
obj.ViewResult = result
|
||||
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
pass
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2013 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2013 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -35,12 +35,13 @@ __title__="FreeCAD Rebar"
|
|||
__author__ = "Yorik van Havre"
|
||||
__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
|
||||
to the given structural object, using the given sketch as profile."""
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Rebar(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderRebar(obj.ViewObject)
|
||||
|
@ -74,7 +75,7 @@ def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name=translate("
|
|||
|
||||
class _CommandRebar:
|
||||
"the Arch Rebar command definition"
|
||||
|
||||
|
||||
def GetResources(self):
|
||||
return {'Pixmap' : 'Arch_Rebar',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Rebar","Rebar"),
|
||||
|
@ -99,7 +100,7 @@ class _CommandRebar:
|
|||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
return
|
||||
else:
|
||||
else:
|
||||
# we have only a base object: open the sketcher
|
||||
FreeCADGui.activateWorkbench("SketcherWorkbench")
|
||||
FreeCADGui.runCommand("Sketcher_NewSketch")
|
||||
|
@ -132,7 +133,7 @@ class _CommandRebar:
|
|||
|
||||
class _Rebar(ArchComponent.Component):
|
||||
"A parametric reinforcement bar (rebar) object"
|
||||
|
||||
|
||||
def __init__(self,obj):
|
||||
ArchComponent.Component.__init__(self,obj)
|
||||
obj.addProperty("App::PropertyLength","Diameter","Arch","The diameter of the bar")
|
||||
|
@ -155,7 +156,7 @@ class _Rebar(ArchComponent.Component):
|
|||
v = DraftGeomUtils.vec(e).normalize()
|
||||
return e.Vertexes[0].Point,v
|
||||
return None,None
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
if len(obj.InList) != 1:
|
||||
return
|
||||
|
@ -237,7 +238,7 @@ class _Rebar(ArchComponent.Component):
|
|||
obj.Shape = Part.makeCompound(shapes)
|
||||
obj.Placement = pl
|
||||
|
||||
|
||||
|
||||
class _ViewProviderRebar(ArchComponent.ViewProviderComponent):
|
||||
"A View Provider for the Rebar object"
|
||||
|
||||
|
|
|
@ -35,12 +35,13 @@ __title__="FreeCAD Roof"
|
|||
__author__ = "Yorik van Havre", "Jonathan Wiedemann"
|
||||
__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.
|
||||
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
|
||||
and the list is automatically complete to match with number of edges in the wire.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Roof(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderRoof(obj.ViewObject)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -32,10 +32,11 @@ else:
|
|||
def translate(ctxt,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
|
||||
given objects. If no object is given, the whole document will be considered."""
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_SectionPlane(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderSectionPlane(obj.ViewObject)
|
||||
|
@ -60,7 +61,7 @@ def makeSectionView(section,name="View"):
|
|||
if not page:
|
||||
page = FreeCAD.ActiveDocument.addObject("Drawing::FeaturePage",translate("Arch","Page"))
|
||||
page.Template = Draft.getParam("template",FreeCAD.getResourceDir()+'Mod/Drawing/Templates/A3_Landscape.svg')
|
||||
|
||||
|
||||
view = FreeCAD.ActiveDocument.addObject("Drawing::FeatureViewPython",name)
|
||||
page.addObject(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.OnlySolids = True
|
||||
self.Type = "SectionPlane"
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
import Part
|
||||
if hasattr(obj.ViewObject,"DisplayLength"):
|
||||
|
@ -126,7 +127,7 @@ class _SectionPlane:
|
|||
|
||||
def onChanged(self,obj,prop):
|
||||
pass
|
||||
|
||||
|
||||
def getNormal(self,obj):
|
||||
return obj.Shape.Faces[0].normalAt(0,0)
|
||||
|
||||
|
@ -142,7 +143,7 @@ class _ViewProviderSectionPlane:
|
|||
def __init__(self,vobj):
|
||||
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","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::PropertyFloat","LineWidth","Base","")
|
||||
vobj.addProperty("App::PropertyColor","LineColor","Base","")
|
||||
|
@ -190,7 +191,7 @@ class _ViewProviderSectionPlane:
|
|||
self.onChanged(vobj,"DisplayLength")
|
||||
self.onChanged(vobj,"LineColor")
|
||||
self.onChanged(vobj,"Transparency")
|
||||
|
||||
|
||||
def getDisplayModes(self,vobj):
|
||||
return ["Default"]
|
||||
|
||||
|
@ -294,7 +295,7 @@ class _ArchDrawingView:
|
|||
if hasattr(self,"spaces"):
|
||||
if round(self.direction.getAngle(FreeCAD.Vector(0,0,1)),Draft.precision()) in [0,round(math.pi,Draft.precision())]:
|
||||
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 += '<g id="' + obj.Name + '"'
|
||||
result += ' transform="'
|
||||
|
@ -306,7 +307,7 @@ class _ArchDrawingView:
|
|||
result += '</g>\n'
|
||||
# print "complete node:",result
|
||||
obj.ViewResult = result
|
||||
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
if prop in ["Source","RenderingMode","ShowCut"]:
|
||||
import Part, DraftGeomUtils
|
||||
|
@ -325,10 +326,10 @@ class _ArchDrawingView:
|
|||
os.append(o)
|
||||
objs = os
|
||||
self.svg = ''
|
||||
|
||||
|
||||
# generating SVG
|
||||
if obj.RenderingMode == "Solid":
|
||||
# render using the Arch Vector Renderer
|
||||
# render using the Arch Vector Renderer
|
||||
import ArchVRM
|
||||
render = ArchVRM.Renderer()
|
||||
render.setWorkingPlane(obj.Source.Placement)
|
||||
|
@ -343,7 +344,7 @@ class _ArchDrawingView:
|
|||
if obj.ShowCut:
|
||||
self.svg += render.getHiddenSVG(linewidth="LWPlaceholder")
|
||||
# print render.info()
|
||||
|
||||
|
||||
else:
|
||||
# render using the Drawing module
|
||||
import Drawing, Part
|
||||
|
@ -405,7 +406,7 @@ class _ArchDrawingView:
|
|||
svgh = svgh.replace('stroke-width="0.35"','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('fill="none"','fill="none"\nstroke-dasharray="DAPlaceholder"')
|
||||
svgh = svgh.replace('fill="none"','fill="none"\nstroke-dasharray="DAPlaceholder"')
|
||||
self.svg += svgh
|
||||
if sshapes:
|
||||
sshapes = Part.makeCompound(sshapes)
|
||||
|
@ -452,5 +453,5 @@ class _ArchDrawingView:
|
|||
return result
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Arch_SectionPlane',_CommandSectionPlane())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -34,10 +34,11 @@ __title__="FreeCAD Site"
|
|||
__author__ = "Yorik van Havre"
|
||||
__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
|
||||
objects from the given list.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Site(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderSite(obj.ViewObject)
|
||||
|
@ -57,7 +58,7 @@ class _CommandSite:
|
|||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
|
||||
def Activated(self):
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
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"))
|
||||
self.Type = "Site"
|
||||
obj.setEditorMode('Height',2)
|
||||
|
||||
|
||||
class _ViewProviderSite(ArchFloor._ViewProviderFloor):
|
||||
"A View Provider for the Site object"
|
||||
def __init__(self,vobj):
|
||||
ArchFloor._ViewProviderFloor.__init__(self,vobj)
|
||||
ArchFloor._ViewProviderFloor.__init__(self,vobj)
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Site_Tree.svg"
|
||||
|
||||
|
||||
def claimChildren(self):
|
||||
return self.Object.Group+[self.Object.Terrain]
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2013 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2013 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -38,11 +38,12 @@ else:
|
|||
def translate(ctxt,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
|
||||
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)"""
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Space(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderSpace(obj.ViewObject)
|
||||
|
@ -57,13 +58,13 @@ def makeSpace(objects=None,baseobj=None,name=translate("Arch","Space")):
|
|||
else:
|
||||
obj.Proxy.addSubobjects(obj,objects)
|
||||
return obj
|
||||
|
||||
|
||||
def addSpaceBoundaries(space,subobjects):
|
||||
"""addSpaceBoundaries(space,subobjects): adds the given subobjects to the given space"""
|
||||
import Draft
|
||||
if Draft.getType(space) == "Space":
|
||||
space.Proxy.addSubobjects(space,subobjects)
|
||||
|
||||
|
||||
def removeSpaceBoundaries(space,objects):
|
||||
"""removeSpaceBoundaries(space,objects): removes the given objects from the given spaces boundaries"""
|
||||
import Draft
|
||||
|
@ -128,7 +129,7 @@ class _Space(ArchComponent.Component):
|
|||
obj.Area = self.getArea(obj)
|
||||
if hasattr(obj,"Area"):
|
||||
obj.setEditorMode('Area',1)
|
||||
|
||||
|
||||
def addSubobjects(self,obj,subobjects):
|
||||
"adds subobjects to this space"
|
||||
objs = obj.Boundaries
|
||||
|
@ -148,10 +149,10 @@ class _Space(ArchComponent.Component):
|
|||
import Part
|
||||
shape = None
|
||||
faces = []
|
||||
|
||||
|
||||
#print "starting compute"
|
||||
# 1: if we have a base shape, we use it
|
||||
|
||||
|
||||
if obj.Base:
|
||||
if obj.Base.isDerivedFrom("Part::Feature"):
|
||||
if obj.Base.Shape.Solids:
|
||||
|
@ -174,7 +175,7 @@ class _Space(ArchComponent.Component):
|
|||
return
|
||||
shape = Part.makeBox(bb.XLength,bb.YLength,bb.ZLength,FreeCAD.Vector(bb.XMin,bb.YMin,bb.ZMin))
|
||||
#print "created shape from boundbox"
|
||||
|
||||
|
||||
# 3: identifing boundary faces
|
||||
goodfaces = []
|
||||
for b in obj.Boundaries:
|
||||
|
@ -185,7 +186,7 @@ class _Space(ArchComponent.Component):
|
|||
#print "adding face ",fn," of object ",b[0].Name
|
||||
|
||||
#print "total: ", len(faces), " faces"
|
||||
|
||||
|
||||
# 4: get cutvolumes from faces
|
||||
cutvolumes = []
|
||||
for f in faces:
|
||||
|
@ -199,7 +200,7 @@ class _Space(ArchComponent.Component):
|
|||
for v in cutvolumes:
|
||||
#print "cutting"
|
||||
shape = shape.cut(v)
|
||||
|
||||
|
||||
# 5: get the final shape
|
||||
if shape:
|
||||
if shape.Solids:
|
||||
|
@ -207,9 +208,9 @@ class _Space(ArchComponent.Component):
|
|||
shape = shape.Solids[0]
|
||||
obj.Shape = shape
|
||||
return
|
||||
|
||||
|
||||
print "Arch: error computing space boundary"
|
||||
|
||||
|
||||
def getArea(self,obj):
|
||||
"returns the horizontal area at the center of the space"
|
||||
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::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::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.Text = ["$label","$area"]
|
||||
vobj.TextAlign = ["Left","Center","Right"]
|
||||
|
@ -254,10 +255,10 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
|||
vobj.Decimals = Draft.getParam("dimPrecision",2)
|
||||
vobj.ShowUnit = Draft.getParam("showUnit",True)
|
||||
vobj.LineSpacing = 1.0
|
||||
|
||||
|
||||
def getDefaultDisplayMode(self):
|
||||
return "Wireframe"
|
||||
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Space_Tree.svg"
|
||||
|
@ -288,12 +289,12 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
|||
self.onChanged(vobj,"FirstLine")
|
||||
self.onChanged(vobj,"LineSpacing")
|
||||
self.onChanged(vobj,"FontName")
|
||||
|
||||
|
||||
def updateData(self,obj,prop):
|
||||
if prop in ["Shape","Label","Tag"]:
|
||||
self.onChanged(obj.ViewObject,"Text")
|
||||
self.onChanged(obj.ViewObject,"TextPosition")
|
||||
|
||||
|
||||
def getTextPosition(self,vobj):
|
||||
pos = FreeCAD.Vector()
|
||||
if hasattr(vobj,"TextPosition"):
|
||||
|
@ -308,7 +309,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
|||
else:
|
||||
pos = vobj.TextPosition
|
||||
return pos
|
||||
|
||||
|
||||
def onChanged(self,vobj,prop):
|
||||
if prop in ["Text","Decimals","ShowUnit"]:
|
||||
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)
|
||||
if text2:
|
||||
self.text2.string.setValues(text2)
|
||||
|
||||
|
||||
elif prop == "FontName":
|
||||
if hasattr(self,"font") and hasattr(vobj,"FontName"):
|
||||
self.font.name = str(vobj.FontName)
|
||||
|
||||
|
||||
elif (prop == "FontSize"):
|
||||
if hasattr(self,"font") and hasattr(vobj,"FontSize"):
|
||||
self.font.size = vobj.FontSize.Value
|
||||
|
||||
|
||||
elif (prop == "FirstLine"):
|
||||
if hasattr(self,"header") and hasattr(vobj,"FontSize") and hasattr(vobj,"FirstLine"):
|
||||
scale = vobj.FirstLine.Value/vobj.FontSize.Value
|
||||
self.header.scaleFactor.setValue([scale,scale,scale])
|
||||
|
||||
|
||||
elif prop == "TextColor":
|
||||
if hasattr(self,"color") and hasattr(vobj,"TextColor"):
|
||||
c = vobj.TextColor
|
||||
self.color.rgb.setValue(c[0],c[1],c[2])
|
||||
|
||||
|
||||
elif prop == "TextPosition":
|
||||
if hasattr(self,"coords") and hasattr(self,"header") and hasattr(vobj,"TextPosition") and hasattr(vobj,"FirstLine"):
|
||||
pos = self.getTextPosition(vobj)
|
||||
self.coords.translation.setValue([pos.x,pos.y,pos.z])
|
||||
up = vobj.FirstLine.Value * vobj.LineSpacing
|
||||
self.header.translation.setValue([0,up,0])
|
||||
|
||||
|
||||
elif prop == "LineSpacing":
|
||||
if hasattr(self,"text1") and hasattr(self,"text2") and hasattr(vobj,"LineSpacing"):
|
||||
self.text1.spacing = vobj.LineSpacing
|
||||
self.text2.spacing = vobj.LineSpacing
|
||||
self.onChanged(vobj,"TextPosition")
|
||||
|
||||
|
||||
elif prop == "TextAlign":
|
||||
if hasattr(self,"text1") and hasattr(self,"text2") and hasattr(vobj,"TextAlign"):
|
||||
from pivy import coin
|
||||
|
@ -397,7 +398,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
|||
else:
|
||||
self.text1.justification = coin.SoAsciiText.LEFT
|
||||
self.text2.justification = coin.SoAsciiText.LEFT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2013 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2013 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -36,11 +36,12 @@ else:
|
|||
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
|
||||
objects with given attributes."""
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Stairs(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderStairs(obj.ViewObject)
|
||||
|
@ -91,15 +92,15 @@ class _Stairs(ArchComponent.Component):
|
|||
"A stairs object"
|
||||
def __init__(self,obj):
|
||||
ArchComponent.Component.__init__(self,obj)
|
||||
|
||||
|
||||
# http://en.wikipedia.org/wiki/Stairs
|
||||
|
||||
|
||||
# base properties
|
||||
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","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"))
|
||||
|
||||
|
||||
# steps properties
|
||||
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"))
|
||||
|
@ -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","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"))
|
||||
|
||||
|
||||
# structural properties
|
||||
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"))
|
||||
|
@ -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","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.Align = ['Left','Right','Center']
|
||||
obj.Landings = ["None","At center","At each corner"]
|
||||
obj.Winders = ["None","All","Corners strict","Corners relaxed"]
|
||||
|
@ -136,9 +137,9 @@ class _Stairs(ArchComponent.Component):
|
|||
self.structures = []
|
||||
pl = obj.Placement
|
||||
landings = 0
|
||||
|
||||
|
||||
base = None
|
||||
|
||||
|
||||
if obj.Base:
|
||||
if hasattr(obj.Base,"Shape"):
|
||||
if obj.Base.Shape:
|
||||
|
@ -159,12 +160,12 @@ class _Stairs(ArchComponent.Component):
|
|||
return
|
||||
if obj.Base.Shape.Faces:
|
||||
return
|
||||
if (len(obj.Base.Shape.Edges) == 1):
|
||||
if (len(obj.Base.Shape.Edges) == 1):
|
||||
edge = obj.Base.Shape.Edges[0]
|
||||
if isinstance(edge.Curve,Part.Line):
|
||||
if obj.Landings == "At center":
|
||||
landings = 1
|
||||
self.makeStraightStairsWithLanding(obj,edge)
|
||||
self.makeStraightStairsWithLanding(obj,edge)
|
||||
else:
|
||||
self.makeStraightStairs(obj,edge)
|
||||
else:
|
||||
|
@ -190,13 +191,13 @@ class _Stairs(ArchComponent.Component):
|
|||
obj.Shape = shape
|
||||
obj.Placement = pl
|
||||
return
|
||||
|
||||
|
||||
base = self.processSubShapes(obj,base,pl)
|
||||
if base:
|
||||
if not base.isNull():
|
||||
obj.Shape = base
|
||||
obj.Placement = pl
|
||||
|
||||
|
||||
# compute step data
|
||||
if obj.NumberOfSteps > 1:
|
||||
l = obj.Length.Value
|
||||
|
@ -441,7 +442,7 @@ class _Stairs(ArchComponent.Component):
|
|||
|
||||
|
||||
def makeStraightStairsWithLanding(self,obj,edge):
|
||||
|
||||
|
||||
"builds a straight staircase with a landing in the middle"
|
||||
|
||||
if obj.NumberOfSteps < 3:
|
||||
|
@ -479,7 +480,7 @@ class _ViewProviderStairs(ArchComponent.ViewProviderComponent):
|
|||
"A View Provider for Stairs"
|
||||
def __init__(self,vobj):
|
||||
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
||||
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Stairs_Tree.svg"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* 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,
|
||||
|
||||
# wood sections
|
||||
|
||||
|
||||
["Wood","1x2in",19,28],
|
||||
["Wood","1x3in",19,64],
|
||||
["Wood","1x4in",19,89],
|
||||
|
@ -55,7 +55,7 @@ Presets = [None,
|
|||
["Wood","1x8in",19,140],
|
||||
["Wood","1x10in",19,184],
|
||||
["Wood","1x12in",19,286],
|
||||
|
||||
|
||||
["Wood","2x2in",38,38],
|
||||
["Wood","2x3in",38,64],
|
||||
["Wood","2x4in",38,89],
|
||||
|
@ -63,15 +63,15 @@ Presets = [None,
|
|||
["Wood","2x8in",38,184],
|
||||
["Wood","2x10in",38,235],
|
||||
["Wood","2x12in",38,286],
|
||||
|
||||
|
||||
["Wood","4x4in",89,89],
|
||||
["Wood","4x6in",89,140],
|
||||
["Wood","6x6in",140,140],
|
||||
["Wood","8x8in",184,184],
|
||||
|
||||
|
||||
# HEA
|
||||
|
||||
|
||||
|
||||
# HEA
|
||||
|
||||
["Steel","HEA100",100,96,5,8],
|
||||
["Steel","HEA120",120,114,5,8],
|
||||
["Steel","HEA140",140,133,5.5,8.5],
|
||||
|
@ -96,9 +96,9 @@ Presets = [None,
|
|||
["Steel","HEA800",300,790,15,28],
|
||||
["Steel","HEA900",300,890,16,30],
|
||||
["Steel","HEA1000",300,990,16.5,31],
|
||||
|
||||
# HEAA
|
||||
|
||||
|
||||
# HEAA
|
||||
|
||||
["Steel","HEAA100",100,91,4.2,5.5],
|
||||
["Steel","HEAA120",120,109,4.2,5.5],
|
||||
["Steel","HEAA140",140,128,4.3,6],
|
||||
|
@ -123,9 +123,9 @@ Presets = [None,
|
|||
["Steel","HEAA800",300,770,14,18],
|
||||
["Steel","HEAA900",300,870,15,20],
|
||||
["Steel","HEAA1000",300,970,16,21],
|
||||
|
||||
# HEB
|
||||
|
||||
|
||||
# HEB
|
||||
|
||||
["Steel","HEB100",100,100,6,10],
|
||||
["Steel","HEB120",120,120,6.5,11],
|
||||
["Steel","HEB140",140,140,7,12],
|
||||
|
@ -150,9 +150,9 @@ Presets = [None,
|
|||
["Steel","HEB800",300,800,17.5,33],
|
||||
["Steel","HEB900",300,900,18.5,35],
|
||||
["Steel","HEB1000",300,1000,19,36],
|
||||
|
||||
# HEM
|
||||
|
||||
|
||||
# HEM
|
||||
|
||||
["Steel","HEM160",166,180,14,23],
|
||||
["Steel","HEM180",186,200,14.5,24],
|
||||
["Steel","HEM200",206,220,15,25],
|
||||
|
@ -174,9 +174,9 @@ Presets = [None,
|
|||
["Steel","HEM800",303,814,21,40],
|
||||
["Steel","HEM900",302,910,21,40],
|
||||
["Steel","HEM1000",302,1008,21,40],
|
||||
|
||||
|
||||
# INP
|
||||
|
||||
|
||||
["Steel","INP80",42,80,3.9,5.9],
|
||||
["Steel","INP100",50,100,4.5,6.8],
|
||||
["Steel","INP120",58,120,5.1,7.7],
|
||||
|
@ -195,8 +195,8 @@ Presets = [None,
|
|||
["Steel","INP380",149,380,13.7,20.5],
|
||||
["Steel","INP400",155,400,14.4,21.6],
|
||||
|
||||
# IPE
|
||||
|
||||
# IPE
|
||||
|
||||
["Steel","IPE100",55,100,4.1,5.7],
|
||||
["Steel","IPE120",64,120,4.4,6.3],
|
||||
["Steel","IPE140",73,140,4.7,6.9],
|
||||
|
@ -214,9 +214,9 @@ Presets = [None,
|
|||
["Steel","IPE500",200,500,10.2,16],
|
||||
["Steel","IPE550",210,550,11.1,17.2],
|
||||
["Steel","IPE600",220,600,12,19],
|
||||
|
||||
# IPEA
|
||||
|
||||
|
||||
# IPEA
|
||||
|
||||
["Steel","IPEA100",55,98,3.6,4.7],
|
||||
["Steel","IPEA120",64,118,3.8,5.1],
|
||||
["Steel","IPEA140",73,138,3.8,5.6],
|
||||
|
@ -234,9 +234,9 @@ Presets = [None,
|
|||
["Steel","IPEA500",200,497,8.4,14.5],
|
||||
["Steel","IPEA550",210,547,9,15.7],
|
||||
["Steel","IPEA600",220,597,9.8,17.5],
|
||||
|
||||
# IPEO
|
||||
|
||||
|
||||
# IPEO
|
||||
|
||||
["Steel","IPEO180",89,182,6.4,9.5],
|
||||
["Steel","IPEO200",102,202,6.2,9.5],
|
||||
["Steel","IPEO220",112,222,6.6,10.2],
|
||||
|
@ -250,9 +250,9 @@ Presets = [None,
|
|||
["Steel","IPEO500",202,506,12,19],
|
||||
["Steel","IPEO550",212,556,12.7,20.2],
|
||||
["Steel","IPEO600",224,610,15,24],
|
||||
|
||||
# IPER
|
||||
|
||||
|
||||
# IPER
|
||||
|
||||
["Steel","IPER140",72,142,5.3,7.8],
|
||||
["Steel","IPER160",81,162,5.6,8.5],
|
||||
["Steel","IPER180",92,183,6,9],
|
||||
|
@ -268,9 +268,9 @@ Presets = [None,
|
|||
["Steel","IPER500",198,508,12.6,20],
|
||||
["Steel","IPER550",210,560,14,22.2],
|
||||
["Steel","IPER600",218,608,14,23],
|
||||
|
||||
# IPEV
|
||||
|
||||
|
||||
# IPEV
|
||||
|
||||
["Steel","IPEV400",182,408,10.6,17.5],
|
||||
["Steel","IPEV450",194,460,12.4,19.6],
|
||||
["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
|
||||
structure element based on the given profile object and the given
|
||||
extrusion height. If no base object is given, you can also specify
|
||||
length and width for a cubic object.'''
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Structure(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderStructure(obj.ViewObject)
|
||||
|
@ -321,7 +322,7 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name=translate
|
|||
obj.Role = "Column"
|
||||
return obj
|
||||
|
||||
def makeStructuralSystem(objects=[],axes=[],name=translate("Arch","StructuralSystem")):
|
||||
def makeStructuralSystem(objects=[],axes=[],name="StructuralSystem"):
|
||||
'''makeStructuralSystem(objects,axes): makes a structural system
|
||||
based on the given objects and axes'''
|
||||
result = []
|
||||
|
@ -335,6 +336,7 @@ def makeStructuralSystem(objects=[],axes=[],name=translate("Arch","StructuralSys
|
|||
objects = [None]
|
||||
for o in objects:
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_StructuralSystem(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderStructuralSystem(obj.ViewObject)
|
||||
|
@ -350,14 +352,15 @@ def makeStructuralSystem(objects=[],axes=[],name=translate("Arch","StructuralSys
|
|||
return result[0]
|
||||
else:
|
||||
return result
|
||||
|
||||
|
||||
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
|
||||
dimensions: W = total width, H = total height, tw = web thickness
|
||||
tw = flange thickness (see http://en.wikipedia.org/wiki/I-beam for
|
||||
reference)'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Profile(obj)
|
||||
obj.Width = W
|
||||
obj.Height = H
|
||||
|
@ -377,8 +380,8 @@ class _CommandStructure:
|
|||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
def Activated(self):
|
||||
|
||||
def Activated(self):
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
self.Length = p.GetFloat("StructureLength",100)
|
||||
self.Width = p.GetFloat("StructureWidth",100)
|
||||
|
@ -422,7 +425,7 @@ class _CommandStructure:
|
|||
self.tracker.length(self.Length)
|
||||
self.tracker.on()
|
||||
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox())
|
||||
|
||||
|
||||
def getPoint(self,point=None,obj=None):
|
||||
"this function is called by the snapper when it has a 3D point"
|
||||
self.tracker.finalize()
|
||||
|
@ -456,7 +459,7 @@ class _CommandStructure:
|
|||
ui = FreeCADGui.UiLoader()
|
||||
w.setWindowTitle(translate("Arch","Structure options").decode("utf8"))
|
||||
grid = QtGui.QGridLayout(w)
|
||||
|
||||
|
||||
# presets box
|
||||
labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8"))
|
||||
valuep = QtGui.QComboBox()
|
||||
|
@ -466,14 +469,14 @@ class _CommandStructure:
|
|||
valuep.addItems(fpresets)
|
||||
grid.addWidget(labelp,0,0,1,1)
|
||||
grid.addWidget(valuep,0,1,1,1)
|
||||
|
||||
|
||||
# length
|
||||
label1 = QtGui.QLabel(translate("Arch","Length").decode("utf8"))
|
||||
self.vLength = ui.createWidget("Gui::InputField")
|
||||
self.vLength.setText(self.FORMAT % self.Length)
|
||||
grid.addWidget(label1,1,0,1,1)
|
||||
grid.addWidget(self.vLength,1,1,1,1)
|
||||
|
||||
|
||||
# width
|
||||
label2 = QtGui.QLabel(translate("Arch","Width").decode("utf8"))
|
||||
self.vWidth = ui.createWidget("Gui::InputField")
|
||||
|
@ -487,7 +490,7 @@ class _CommandStructure:
|
|||
self.vHeight.setText(self.FORMAT % self.Height)
|
||||
grid.addWidget(label3,3,0,1,1)
|
||||
grid.addWidget(self.vHeight,3,1,1,1)
|
||||
|
||||
|
||||
# horizontal button
|
||||
value5 = QtGui.QPushButton(translate("Arch","Rotate").decode("utf8"))
|
||||
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(value5,QtCore.SIGNAL("pressed()"),self.rotate)
|
||||
return w
|
||||
|
||||
|
||||
def update(self,point,info):
|
||||
"this function is called by the Snapper when the mouse is moved"
|
||||
if FreeCADGui.Control.activeDialog():
|
||||
|
@ -520,7 +523,7 @@ class _CommandStructure:
|
|||
else:
|
||||
delta = Vector(self.Length/2,0,0)
|
||||
self.tracker.pos(point.add(delta))
|
||||
|
||||
|
||||
def setWidth(self,d):
|
||||
self.Width = d
|
||||
self.tracker.width(d)
|
||||
|
@ -537,7 +540,7 @@ class _CommandStructure:
|
|||
self.continueCmd = bool(i)
|
||||
if hasattr(FreeCADGui,"draftToolBar"):
|
||||
FreeCADGui.draftToolBar.continueMode = bool(i)
|
||||
|
||||
|
||||
def setPreset(self,i):
|
||||
if i > 0:
|
||||
self.vLength.setText(self.FORMAT % float(Presets[i][2]))
|
||||
|
@ -546,7 +549,7 @@ class _CommandStructure:
|
|||
self.Profile = i
|
||||
else:
|
||||
self.Profile = 0
|
||||
|
||||
|
||||
def rotate(self):
|
||||
l = self.Length
|
||||
w = self.Width
|
||||
|
@ -554,7 +557,7 @@ class _CommandStructure:
|
|||
self.vLength.setText(self.FORMAT % h)
|
||||
self.vHeight.setText(self.FORMAT % w)
|
||||
self.vWidth.setText(self.FORMAT % l)
|
||||
|
||||
|
||||
class _Structure(ArchComponent.Component):
|
||||
"The Structure object"
|
||||
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"))
|
||||
self.Type = "Structure"
|
||||
obj.Role = Roles
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
"creates the structure shape"
|
||||
|
||||
|
||||
import Part, DraftGeomUtils
|
||||
|
||||
|
||||
normal,length,width,height = self.getDefaultValues(obj)
|
||||
|
||||
# creating base shape
|
||||
|
@ -613,7 +616,7 @@ class _Structure(ArchComponent.Component):
|
|||
if base.Wires[0].isClosed():
|
||||
base = Part.Face(base.Wires[0])
|
||||
base = base.extrude(normal)
|
||||
|
||||
|
||||
elif obj.Base.isDerivedFrom("Mesh::Feature"):
|
||||
if obj.Base.Mesh.isSolid():
|
||||
if obj.Base.Mesh.countComponents() == 1:
|
||||
|
@ -632,7 +635,7 @@ class _Structure(ArchComponent.Component):
|
|||
normal = normal.multiply(height)
|
||||
base = Part.Face(base[0])
|
||||
base = base.extrude(normal)
|
||||
|
||||
|
||||
base = self.processSubShapes(obj,base,pl)
|
||||
self.applyShape(obj,base,pl)
|
||||
|
||||
|
@ -676,7 +679,7 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
|||
def getIcon(self):
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Structure_Tree.svg"
|
||||
|
||||
|
||||
def updateData(self,obj,prop):
|
||||
if prop == "Nodes":
|
||||
if obj.Nodes:
|
||||
|
@ -687,7 +690,7 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
|||
self.coords.point.setValues(0,len(p),p)
|
||||
self.pointset.numPoints.setValue(len(p))
|
||||
self.lineset.coordIndex.setValues(0,len(p)+1,range(len(p))+[-1])
|
||||
|
||||
|
||||
def onChanged(self,vobj,prop):
|
||||
if prop == "ShowNodes":
|
||||
if hasattr(self,"nodes"):
|
||||
|
@ -729,14 +732,14 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
|||
|
||||
class _Profile(Draft._DraftObject):
|
||||
"A parametric beam profile object"
|
||||
|
||||
|
||||
def __init__(self,obj):
|
||||
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","WebThickness","Draft","Thickness of the webs").WebThickness = 3
|
||||
obj.addProperty("App::PropertyLength","FlangeThickness","Draft","Thickness of the flange").FlangeThickness = 2
|
||||
Draft._DraftObject.__init__(self,obj,"Profile")
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
import Part
|
||||
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::PropertyIntegerList","Exclude","Arch",translate("Arch","The element numbers to exclude when this structure is based on axes"))
|
||||
self.Type = "StructuralSystem"
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
"creates the structure shape"
|
||||
|
||||
|
||||
import Part, DraftGeomUtils
|
||||
|
||||
|
||||
# creating base shape
|
||||
pl = obj.Placement
|
||||
if obj.Base:
|
||||
|
@ -780,7 +783,7 @@ class _StructuralSystem(ArchComponent.Component):
|
|||
return
|
||||
|
||||
base = None
|
||||
|
||||
|
||||
# applying axes
|
||||
pts = self.getAxisPoints(obj)
|
||||
apl = self.getAxisPlacement(obj)
|
||||
|
@ -813,7 +816,7 @@ class _StructuralSystem(ArchComponent.Component):
|
|||
obj.Shape = base
|
||||
if not pl.isNull():
|
||||
obj.Placement = pl
|
||||
|
||||
|
||||
def getAxisPoints(self,obj):
|
||||
"returns the gridpoints of linked axes"
|
||||
import DraftGeomUtils
|
||||
|
@ -825,7 +828,7 @@ class _StructuralSystem(ArchComponent.Component):
|
|||
set1 = obj.Axes[0].Shape.Edges
|
||||
set2 = obj.Axes[1].Shape.Edges
|
||||
for e1 in set1:
|
||||
for e2 in set2:
|
||||
for e2 in set2:
|
||||
pts.extend(DraftGeomUtils.findIntersection(e1,e2))
|
||||
return pts
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2011 *
|
||||
#* Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* 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
|
||||
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
|
||||
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.'''
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Wall(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderWall(obj.ViewObject)
|
||||
|
@ -101,7 +102,7 @@ def joinWalls(walls,delete=False):
|
|||
FreeCAD.ActiveDocument.recompute()
|
||||
base.ViewObject.show()
|
||||
return base
|
||||
|
||||
|
||||
def mergeShapes(w1,w2):
|
||||
"returns a Shape built on two walls that share same properties and have a coincident endpoint"
|
||||
if not areSameWallTypes([w1,w2]):
|
||||
|
@ -110,10 +111,10 @@ def mergeShapes(w1,w2):
|
|||
return None
|
||||
if w1.Base.Shape.Faces or w2.Base.Shape.Faces:
|
||||
return None
|
||||
|
||||
|
||||
# TODO fix this
|
||||
return None
|
||||
|
||||
|
||||
eds = w1.Base.Shape.Edges + w2.Base.Shape.Edges
|
||||
import DraftGeomUtils
|
||||
w = DraftGeomUtils.findWires(eds)
|
||||
|
@ -154,7 +155,7 @@ class _CommandWall:
|
|||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
|
||||
def Activated(self):
|
||||
self.Align = "Center"
|
||||
self.Length = None
|
||||
|
@ -281,25 +282,25 @@ class _CommandWall:
|
|||
ui = FreeCADGui.UiLoader()
|
||||
w.setWindowTitle(translate("Arch","Wall options").decode("utf8"))
|
||||
grid = QtGui.QGridLayout(w)
|
||||
|
||||
|
||||
label5 = QtGui.QLabel(translate("Arch","Length").decode("utf8"))
|
||||
self.Length = ui.createWidget("Gui::InputField")
|
||||
self.Length.setText("0.00 mm")
|
||||
grid.addWidget(label5,0,0,1,1)
|
||||
grid.addWidget(self.Length,0,1,1,1)
|
||||
|
||||
|
||||
label1 = QtGui.QLabel(translate("Arch","Width").decode("utf8"))
|
||||
value1 = ui.createWidget("Gui::InputField")
|
||||
value1.setText(self.FORMAT % self.Width)
|
||||
grid.addWidget(label1,1,0,1,1)
|
||||
grid.addWidget(value1,1,1,1,1)
|
||||
|
||||
|
||||
label2 = QtGui.QLabel(translate("Arch","Height").decode("utf8"))
|
||||
value2 = ui.createWidget("Gui::InputField")
|
||||
value2.setText(self.FORMAT % self.Height)
|
||||
grid.addWidget(label2,2,0,1,1)
|
||||
grid.addWidget(value2,2,1,1,1)
|
||||
|
||||
|
||||
label3 = QtGui.QLabel(translate("Arch","Alignment").decode("utf8"))
|
||||
value3 = QtGui.QComboBox()
|
||||
items = ["Center","Left","Right"]
|
||||
|
@ -307,7 +308,7 @@ class _CommandWall:
|
|||
value3.setCurrentIndex(items.index(self.Align))
|
||||
grid.addWidget(label3,3,0,1,1)
|
||||
grid.addWidget(value3,3,1,1,1)
|
||||
|
||||
|
||||
label4 = QtGui.QLabel(translate("Arch","Con&tinue").decode("utf8"))
|
||||
value4 = QtGui.QCheckBox()
|
||||
value4.setObjectName("ContinueCmd")
|
||||
|
@ -324,7 +325,7 @@ class _CommandWall:
|
|||
QtCore.QObject.connect(value3,QtCore.SIGNAL("currentIndexChanged(int)"),self.setAlign)
|
||||
QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
|
||||
return w
|
||||
|
||||
|
||||
def setWidth(self,d):
|
||||
self.Width = d
|
||||
self.tracker.width(d)
|
||||
|
@ -354,7 +355,7 @@ class _CommandMergeWalls:
|
|||
|
||||
def Activated(self):
|
||||
walls = FreeCADGui.Selection.getSelection()
|
||||
if len(walls) == 1:
|
||||
if len(walls) == 1:
|
||||
if Draft.getType(walls[0]) == "Wall":
|
||||
ostr = "FreeCAD.ActiveDocument."+ walls[0].Name
|
||||
ok = False
|
||||
|
@ -382,7 +383,7 @@ class _CommandMergeWalls:
|
|||
FreeCADGui.addModule("Arch")
|
||||
FreeCADGui.doCommand("Arch.joinWalls(FreeCADGui.Selection.getSelection(),delete=True)")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
||||
|
||||
|
||||
class _Wall(ArchComponent.Component):
|
||||
"The Wall object"
|
||||
|
@ -398,10 +399,10 @@ class _Wall(ArchComponent.Component):
|
|||
obj.Align = ['Left','Right','Center']
|
||||
obj.Role = Roles
|
||||
self.Type = "Wall"
|
||||
|
||||
|
||||
def execute(self,obj):
|
||||
"builds the wall shape"
|
||||
|
||||
|
||||
import Part, DraftGeomUtils
|
||||
pl = obj.Placement
|
||||
normal,length,width,height = self.getDefaultValues(obj)
|
||||
|
@ -417,7 +418,7 @@ class _Wall(ArchComponent.Component):
|
|||
if not obj.Base.Shape.Solids:
|
||||
# let pass invalid objects if they have solids...
|
||||
return
|
||||
|
||||
|
||||
if hasattr(obj,"Face"):
|
||||
if obj.Face > 0:
|
||||
if len(obj.Base.Shape.Faces) >= obj.Face:
|
||||
|
@ -455,7 +456,7 @@ class _Wall(ArchComponent.Component):
|
|||
else:
|
||||
base = None
|
||||
FreeCAD.Console.PrintError(str(translate("Arch","Error: Invalid base object")))
|
||||
|
||||
|
||||
elif obj.Base.isDerivedFrom("Mesh::Feature"):
|
||||
if obj.Base.Mesh.isSolid():
|
||||
if obj.Base.Mesh.countComponents() == 1:
|
||||
|
@ -469,10 +470,10 @@ class _Wall(ArchComponent.Component):
|
|||
# computing a shape from scratch
|
||||
if length and width and height:
|
||||
base = Part.makeBox(length,width,height)
|
||||
|
||||
|
||||
base = self.processSubShapes(obj,base,pl)
|
||||
self.applyShape(obj,base,pl)
|
||||
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
self.hideSubobjects(obj,prop)
|
||||
ArchComponent.Component.onChanged(self,obj,prop)
|
||||
|
|
|
@ -43,7 +43,7 @@ WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane",
|
|||
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
|
||||
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
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = name
|
||||
obj.Label = translate("Arch",name)
|
||||
_Window(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderWindow(obj.ViewObject)
|
||||
|
@ -515,18 +515,18 @@ class _CommandWindow:
|
|||
"sets up a taskbox widget"
|
||||
w = QtGui.QWidget()
|
||||
ui = FreeCADGui.UiLoader()
|
||||
w.setWindowTitle(translate("Arch","Window options"))
|
||||
w.setWindowTitle(translate("Arch","Window options").decode("utf8"))
|
||||
grid = QtGui.QGridLayout(w)
|
||||
|
||||
# sill height
|
||||
labels = QtGui.QLabel(translate("Arch","Sill height"))
|
||||
labels = QtGui.QLabel(translate("Arch","Sill height").decode("utf8"))
|
||||
values = ui.createWidget("Gui::InputField")
|
||||
grid.addWidget(labels,0,0,1,1)
|
||||
grid.addWidget(values,0,1,1,1)
|
||||
QtCore.QObject.connect(values,QtCore.SIGNAL("valueChanged(double)"),self.setSill)
|
||||
|
||||
# presets box
|
||||
labelp = QtGui.QLabel(translate("Arch","Preset"))
|
||||
labelp = QtGui.QLabel(translate("Arch","Preset").decode("utf8"))
|
||||
valuep = QtGui.QComboBox()
|
||||
valuep.addItems(["Create from scratch"]+WindowPresets)
|
||||
valuep.setCurrentIndex(self.Preset)
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2009, 2010 *
|
||||
#* Yorik van Havre <yorik@uncreated.net>, Ken Cline <cline@frii.com> *
|
||||
#* Copyright (c) 2009, 2010 *
|
||||
#* Yorik van Havre <yorik@uncreated.net>, Ken Cline <cline@frii.com> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
|
@ -223,7 +223,7 @@ class DraftTool:
|
|||
self.ui = None
|
||||
self.call = None
|
||||
self.support = None
|
||||
self.point = None
|
||||
self.point = None
|
||||
self.commitList = []
|
||||
self.doc = FreeCAD.ActiveDocument
|
||||
if not self.doc:
|
||||
|
@ -303,7 +303,7 @@ class DraftTool:
|
|||
|
||||
#---------------------------------------------------------------------------
|
||||
# Helper tools
|
||||
#---------------------------------------------------------------------------
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class SelectPlane(DraftTool):
|
||||
"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")}
|
||||
|
||||
def Activated(self):
|
||||
Line.Activated(self,name=translate("draft","BezCurve"))
|
||||
Line.Activated(self,name=translate("draft","BezCurve").decode("utf8"))
|
||||
if self.doc:
|
||||
self.bezcurvetrack = bezcurveTracker()
|
||||
|
||||
|
@ -860,7 +860,7 @@ class Rectangle(Creator):
|
|||
|
||||
def finish(self,closed=False,cont=False):
|
||||
"terminates the operation and closes the poly if asked"
|
||||
Creator.finish(self)
|
||||
Creator.finish(self)
|
||||
if self.ui:
|
||||
self.rect.off()
|
||||
self.rect.finalize()
|
||||
|
@ -1121,11 +1121,11 @@ class Arc(Creator):
|
|||
self.linetrack.on()
|
||||
msg(translate("draft", "Pick radius:\n"))
|
||||
if self.planetrack:
|
||||
self.planetrack.set(self.point)
|
||||
self.planetrack.set(self.point)
|
||||
elif (self.step == 1): # choose radius
|
||||
if self.closedCircle:
|
||||
self.drawArc()
|
||||
else:
|
||||
else:
|
||||
self.ui.labelRadius.setText("Start angle")
|
||||
self.ui.radiusValue.setText(self.ui.AFORMAT % 0)
|
||||
self.linetrack.p1(self.center)
|
||||
|
@ -1394,8 +1394,8 @@ class Polygon(Creator):
|
|||
|
||||
def drawPolygon(self):
|
||||
"actually draws the FreeCAD object"
|
||||
rot,sup,pts,fil = self.getStrings()
|
||||
if Draft.getParam("UsePartPrimitives",False):
|
||||
rot,sup,pts,fil = self.getStrings()
|
||||
if Draft.getParam("UsePartPrimitives",False):
|
||||
self.commit(translate("draft","Create Polygon"),
|
||||
['import Part',
|
||||
'pl=FreeCAD.Placement()',
|
||||
|
@ -1468,7 +1468,7 @@ class Ellipse(Creator):
|
|||
|
||||
def finish(self,closed=False,cont=False):
|
||||
"terminates the operation and closes the poly if asked"
|
||||
Creator.finish(self)
|
||||
Creator.finish(self)
|
||||
if self.ui:
|
||||
self.rect.off()
|
||||
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])+')'])
|
||||
elif self.arcmode:
|
||||
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:
|
||||
self.commit(translate("draft","Create Dimension"),
|
||||
['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.node = [self.node[1]]
|
||||
self.link = None
|
||||
|
||||
|
||||
def selectEdge(self):
|
||||
self.selectmode = not(self.selectmode)
|
||||
|
||||
|
@ -1888,8 +1888,8 @@ class Dimension(Creator):
|
|||
self.link = [self.link[0],ob]
|
||||
else:
|
||||
msg(translate("draft", "Edges don't intersect!\n"))
|
||||
self.finish()
|
||||
return
|
||||
self.finish()
|
||||
return
|
||||
self.dimtrack.on()
|
||||
else:
|
||||
self.node.append(self.point)
|
||||
|
@ -1963,18 +1963,18 @@ class ShapeString(Creator):
|
|||
|
||||
dquote = '"'
|
||||
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:
|
||||
String = dquote + self.SString + dquote
|
||||
String = dquote + self.SString + dquote
|
||||
Size = str(self.SSSize) # 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(FFile): " str(type(FFile)))
|
||||
|
||||
try:
|
||||
qr,sup,points,fil = self.getStrings()
|
||||
FreeCADGui.addModule("Draft")
|
||||
qr,sup,points,fil = self.getStrings()
|
||||
FreeCADGui.addModule("Draft")
|
||||
self.commit(translate("draft","Create ShapeString"),
|
||||
['ss=Draft.makeShapeString(String='+String+',FontFile='+FFile+',Size='+Size+',Tracking='+Tracking+')',
|
||||
'plm=FreeCAD.Placement()',
|
||||
|
@ -2008,15 +2008,15 @@ class ShapeString(Creator):
|
|||
self.ssBase = Vector(numx,numy,numz)
|
||||
self.ui.SSUi() #move on to next step in parameter entry
|
||||
|
||||
def numericSSize(self,ssize):
|
||||
'''this function is called by the toolbar when valid size parameter
|
||||
has been entered. '''
|
||||
def numericSSize(self,ssize):
|
||||
'''this function is called by the toolbar when valid size parameter
|
||||
has been entered. '''
|
||||
self.SSSize = ssize
|
||||
self.ui.STrackUi()
|
||||
self.ui.STrackUi()
|
||||
|
||||
def numericSTrack(self,strack):
|
||||
'''this function is called by the toolbar when valid size parameter
|
||||
has been entered. ?'''
|
||||
'''this function is called by the toolbar when valid size parameter
|
||||
has been entered. ?'''
|
||||
self.SSTrack = strack
|
||||
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")}
|
||||
|
||||
def Activated(self):
|
||||
self.name = translate("draft","Move")
|
||||
self.name = translate("draft","Move").decode("utf8")
|
||||
Modifier.Activated(self,self.name)
|
||||
self.ghost = None
|
||||
if self.ui:
|
||||
|
@ -2211,7 +2211,7 @@ class ApplyStyle(Modifier):
|
|||
if (ob.Type == "App::DocumentObjectGroup"):
|
||||
c.extend(self.formatGroup(ob))
|
||||
else:
|
||||
c.append('Draft.formatObject(FreeCAD.ActiveDocument.'+ob.Name+')')
|
||||
c.append('Draft.formatObject(FreeCAD.ActiveDocument.'+ob.Name+')')
|
||||
|
||||
class Rotate(Modifier):
|
||||
"The Draft_Rotate FreeCAD command definition"
|
||||
|
@ -2312,7 +2312,7 @@ class Rotate(Modifier):
|
|||
if (currentrad != 0):
|
||||
angle = DraftVecUtils.angle(plane.u, self.point.sub(self.center), plane.axis)
|
||||
else: angle = 0
|
||||
if (angle < self.firstangle):
|
||||
if (angle < self.firstangle):
|
||||
sweep = (2*math.pi-self.firstangle)+angle
|
||||
else:
|
||||
sweep = angle - self.firstangle
|
||||
|
@ -2355,7 +2355,7 @@ class Rotate(Modifier):
|
|||
angle = self.point.sub(self.center).getAngle(plane.u)
|
||||
if DraftVecUtils.project(self.point.sub(self.center), plane.v).getAngle(plane.v) > 1:
|
||||
angle = -angle
|
||||
if (angle < self.firstangle):
|
||||
if (angle < self.firstangle):
|
||||
sweep = (2*math.pi-self.firstangle)+angle
|
||||
else:
|
||||
sweep = angle - self.firstangle
|
||||
|
@ -2595,7 +2595,7 @@ class Upgrade(Modifier):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
if FreeCADGui.Selection.getSelection():
|
||||
FreeCADGui.addModule("Draft")
|
||||
|
@ -2624,7 +2624,7 @@ class Downgrade(Modifier):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
if FreeCADGui.Selection.getSelection():
|
||||
FreeCADGui.addModule("Draft")
|
||||
|
@ -2697,7 +2697,7 @@ class Trimex(Modifier):
|
|||
self.edges = self.obj.Shape.Wires[0].Edges
|
||||
self.edges = DraftGeomUtils.sortEdges(self.edges)
|
||||
else:
|
||||
self.edges = self.obj.Shape.Edges
|
||||
self.edges = self.obj.Shape.Edges
|
||||
self.ghost = []
|
||||
lc = self.obj.ViewObject.LineColor
|
||||
sc = (lc[0],lc[1],lc[2])
|
||||
|
@ -2856,9 +2856,9 @@ class Trimex(Modifier):
|
|||
ghost.on()
|
||||
|
||||
# resetting the visible edges
|
||||
if not reverse:
|
||||
if not reverse:
|
||||
li = list(range(npoint+1,len(self.edges)))
|
||||
else:
|
||||
else:
|
||||
li = list(range(npoint-1,-1,-1))
|
||||
for i in li:
|
||||
edge = self.edges[i]
|
||||
|
@ -2896,21 +2896,21 @@ class Trimex(Modifier):
|
|||
self.doc.openTransaction("Trim/extend")
|
||||
if Draft.getType(self.obj) in ["Wire","BSpline"]:
|
||||
p = []
|
||||
if self.placement:
|
||||
if self.placement:
|
||||
invpl = self.placement.inverse()
|
||||
for v in newshape.Vertexes:
|
||||
np = v.Point
|
||||
if self.placement:
|
||||
if self.placement:
|
||||
np = invpl.multVec(np)
|
||||
p.append(np)
|
||||
self.obj.Points = p
|
||||
elif Draft.getType(self.obj) == "Part::Line":
|
||||
p = []
|
||||
if self.placement:
|
||||
if self.placement:
|
||||
invpl = self.placement.inverse()
|
||||
for v in newshape.Vertexes:
|
||||
np = v.Point
|
||||
if self.placement:
|
||||
if self.placement:
|
||||
np = invpl.multVec(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)):
|
||||
|
@ -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")}
|
||||
|
||||
def Activated(self):
|
||||
self.name = translate("draft","Scale")
|
||||
self.name = translate("draft","Scale").decode("utf8")
|
||||
Modifier.Activated(self,self.name)
|
||||
self.ghost = None
|
||||
if self.ui:
|
||||
|
@ -3134,7 +3134,7 @@ class Drawing(Modifier):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if not sel:
|
||||
|
@ -3161,14 +3161,14 @@ class Drawing(Modifier):
|
|||
if obj.isDerivedFrom("Drawing::FeatureView"):
|
||||
otherProjection = obj
|
||||
break
|
||||
sel.reverse()
|
||||
sel.reverse()
|
||||
for obj in sel:
|
||||
if ( obj.ViewObject.isVisible() and not obj.isDerivedFrom("Drawing::FeatureView")
|
||||
and not obj.isDerivedFrom("Drawing::FeaturePage") ):
|
||||
name = 'View'+obj.Name
|
||||
# no reason to remove the old one...
|
||||
#oldobj = self.page.getObject(name)
|
||||
#if oldobj:
|
||||
#if oldobj:
|
||||
# self.doc.removeObject(oldobj.Name)
|
||||
Draft.makeDrawingView(obj,self.page,otherProjection=otherProjection)
|
||||
self.doc.recompute()
|
||||
|
@ -3240,7 +3240,7 @@ class Edit(Modifier):
|
|||
self.call = self.view.addEventCallback("SoEvent",selectObject)
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
if self.doc:
|
||||
self.obj = FreeCADGui.Selection.getSelection()
|
||||
|
@ -3293,10 +3293,10 @@ class Edit(Modifier):
|
|||
self.editpoints.append(self.obj.Shape.Vertexes[2].Point)
|
||||
v = self.obj.Shape.Vertexes
|
||||
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.by = v[2].Point.sub(v[1].Point)
|
||||
if self.obj.Height < 0:
|
||||
if self.obj.Height < 0:
|
||||
self.by = self.by.negative()
|
||||
elif Draft.getType(self.obj) == "Polygon":
|
||||
self.editpoints.append(self.obj.Placement.Base)
|
||||
|
@ -3383,15 +3383,15 @@ class Edit(Modifier):
|
|||
if 'EditNode' in info["Component"]:
|
||||
self.delPoint(int(info["Component"][8:]))
|
||||
# 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())):
|
||||
if 'EditNode' in info["Component"]:
|
||||
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())):
|
||||
if 'EditNode' in info["Component"]:
|
||||
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())):
|
||||
if 'EditNode' in info["Component"]:
|
||||
self.smoothBezPoint(int(info["Component"][8:]), info, 'Symmetric')
|
||||
|
@ -3521,7 +3521,7 @@ class Edit(Modifier):
|
|||
elif self.editing == 2:
|
||||
self.obj.Dimline = v
|
||||
elif self.editing == 3:
|
||||
self.obj.ViewObject.TextPosition = v
|
||||
self.obj.ViewObject.TextPosition = v
|
||||
elif Draft.getType(self.obj) == "Space":
|
||||
if self.editing == 0:
|
||||
self.obj.ViewObject.TextPosition = v
|
||||
|
@ -3603,7 +3603,7 @@ class Edit(Modifier):
|
|||
if ( uNewPoint > uPoints[i] ) and ( uNewPoint < uPoints[i+1] ):
|
||||
pts.insert(i+1, self.invpl.multVec(point))
|
||||
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] ) :
|
||||
pts.append(self.invpl.multVec(point))
|
||||
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 len(self.obj.Points) <= 2:
|
||||
msg(translate("draft", "Active object must have more than two points/nodes\n"),'warning')
|
||||
else:
|
||||
else:
|
||||
pts = self.obj.Points
|
||||
pts.pop(point)
|
||||
self.doc.openTransaction("Edit "+self.obj.Name)
|
||||
|
@ -3707,7 +3707,7 @@ class Edit(Modifier):
|
|||
self.obj.Continuity=newcont
|
||||
self.doc.commitTransaction()
|
||||
self.resetTrackers()
|
||||
|
||||
|
||||
def resetTrackersBezier(self):
|
||||
knotmarkers = (coin.SoMarkerSet.DIAMOND_FILLED_9_9,#sharp
|
||||
coin.SoMarkerSet.SQUARE_FILLED_9_9, #tangent
|
||||
|
@ -3934,7 +3934,7 @@ class Shape2DView(Modifier):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
faces = []
|
||||
objs = []
|
||||
|
@ -3973,7 +3973,7 @@ class Draft2Sketch(Modifier):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
allSketches = True
|
||||
|
@ -3990,11 +3990,11 @@ class Draft2Sketch(Modifier):
|
|||
if not sel:
|
||||
return
|
||||
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"),
|
||||
lines + ['FreeCAD.ActiveDocument.recompute()'])
|
||||
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"),
|
||||
lines + ['FreeCAD.ActiveDocument.recompute()'])
|
||||
else:
|
||||
|
@ -4006,7 +4006,7 @@ class Draft2Sketch(Modifier):
|
|||
lines.append("Draft.makeSketch(FreeCAD.ActiveDocument."+obj.Name+",autoconstraints=True)")
|
||||
elif obj.isDerivedFrom("Part::Feature"):
|
||||
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"),
|
||||
lines + ['FreeCAD.ActiveDocument.recompute()'])
|
||||
self.finish()
|
||||
|
@ -4031,7 +4031,7 @@ class Array(Modifier):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
if FreeCADGui.Selection.getSelection():
|
||||
obj = FreeCADGui.Selection.getSelection()[0]
|
||||
|
@ -4061,7 +4061,7 @@ class PathArray(Modifier):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
sel = FreeCADGui.Selection.getSelectionEx()
|
||||
if sel:
|
||||
|
@ -4131,7 +4131,7 @@ class Point(Creator):
|
|||
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(),self.callbackMove)
|
||||
commitlist = []
|
||||
if Draft.getParam("UsePartPrimitives",False):
|
||||
# using
|
||||
# using
|
||||
commitlist.append((translate("draft","Create Point"),
|
||||
['point = FreeCAD.ActiveDocument.addObject("Part::Vertex","Point")',
|
||||
'point.X = '+str(self.stack[0][0]),
|
||||
|
@ -4185,7 +4185,7 @@ class Draft_Clone(Modifier):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
if FreeCADGui.Selection.getSelection():
|
||||
FreeCAD.ActiveDocument.openTransaction("Clone")
|
||||
|
@ -4256,7 +4256,7 @@ class Draft_Facebinder(Creator):
|
|||
self.proceed()
|
||||
|
||||
def proceed(self):
|
||||
if self.call:
|
||||
if self.call:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
if FreeCADGui.Selection.getSelection():
|
||||
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
|
||||
FreeCAD.activeDraftCommand = None
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user