Arch: Fixed bugs when working without GUI
This commit is contained in:
parent
0fda229597
commit
eea27448e9
|
@ -41,7 +41,8 @@ def makeAxis(num=5,size=1000,name=translate("Arch","Axes")):
|
|||
based on the given number of axes and interval distances'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
|
||||
_Axis(obj)
|
||||
_ViewProviderAxis(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderAxis(obj.ViewObject)
|
||||
if num:
|
||||
dist = []
|
||||
angles = []
|
||||
|
|
|
@ -34,12 +34,13 @@ __title__="FreeCAD Building"
|
|||
__author__ = "Yorik van Havre"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
def makeBuilding(objectslist=None,join=False,name=translate("Arch","Building")):
|
||||
'''makeBuilding(objectslist,[joinmode]): creates a building including the
|
||||
objects from the given list. If joinmode is True, components will be joined.'''
|
||||
def makeBuilding(objectslist=None,baseobj=None,name=translate("Arch","Building")):
|
||||
'''makeBuilding(objectslist): creates a building including the
|
||||
objects from the given list.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
_Building(obj)
|
||||
_ViewProviderBuilding(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderBuilding(obj.ViewObject)
|
||||
if objectslist:
|
||||
obj.Group = objectslist
|
||||
return obj
|
||||
|
|
|
@ -34,10 +34,9 @@ __title__="FreeCAD Arch Floor"
|
|||
__author__ = "Yorik van Havre"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
def makeFloor(objectslist=None,join=True,name=translate("Arch","Floor")):
|
||||
'''makeFloor(objectslist,[joinmode]): creates a floor including the
|
||||
objects from the given list. If joinmode is False, components will
|
||||
not be joined.'''
|
||||
def makeFloor(objectslist=None,baseobj=None,name=translate("Arch","Floor")):
|
||||
'''makeFloor(objectslist): creates a floor including the
|
||||
objects from the given list.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
_Floor(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
|
|
|
@ -38,15 +38,19 @@ __url__ = "http://www.freecadweb.org"
|
|||
# Possible roles for frames
|
||||
Roles = ['Covering','Member','Railing','Shading Device','Tendon']
|
||||
|
||||
def makeFrame(base,profile,name=translate("Arch","Frame")):
|
||||
"""makeFrame(base,profile,[name]): creates a frame object from a base sketch (or any other object
|
||||
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)
|
||||
_Frame(obj)
|
||||
_ViewProviderFrame(obj.ViewObject)
|
||||
obj.Base = base
|
||||
obj.Profile = profile
|
||||
#profile.ViewObject.hide()
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderFrame(obj.ViewObject)
|
||||
if baseobj:
|
||||
obj.Base = baseobj
|
||||
if profile:
|
||||
obj.Profile = profile
|
||||
if FreeCAD.GuiUp:
|
||||
profile.ViewObject.hide()
|
||||
return obj
|
||||
|
||||
class _CommandFrame:
|
||||
|
|
|
@ -42,7 +42,9 @@ def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name=translate("
|
|||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Rebar(obj)
|
||||
_ViewProviderRebar(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderRebar(obj.ViewObject)
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Rebar")
|
||||
if hasattr(sketch,"Support"):
|
||||
if sketch.Support:
|
||||
if isinstance(sketch.Support,tuple):
|
||||
|
@ -51,7 +53,8 @@ def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name=translate("
|
|||
elif sketch.Support == baseobj:
|
||||
sketch.Support = None
|
||||
obj.Base = sketch
|
||||
sketch.ViewObject.hide()
|
||||
if FreeCAD.GuiUp:
|
||||
sketch.ViewObject.hide()
|
||||
a = baseobj.Armatures
|
||||
a.append(obj)
|
||||
baseobj.Armatures = a
|
||||
|
@ -66,7 +69,6 @@ def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name=translate("
|
|||
else:
|
||||
obj.OffsetStart = p.GetFloat("RebarOffset",30)
|
||||
obj.OffsetEnd = p.GetFloat("RebarOffset",30)
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Rebar")
|
||||
return obj
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ def makeRoof(baseobj=None,facenr=1,angle=45,name=translate("Arch","Roof")):
|
|||
= roof).'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Roof(obj)
|
||||
_ViewProviderRoof(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderRoof(obj.ViewObject)
|
||||
if baseobj:
|
||||
obj.Base = baseobj
|
||||
obj.Face = facenr
|
||||
|
|
|
@ -37,7 +37,8 @@ def makeSectionPlane(objectslist=None,name=translate("Arch","Section")):
|
|||
given objects. If no object is given, the whole document will be considered."""
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
|
||||
_SectionPlane(obj)
|
||||
_ViewProviderSectionPlane(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderSectionPlane(obj.ViewObject)
|
||||
if objectslist:
|
||||
g = []
|
||||
for o in objectslist:
|
||||
|
|
|
@ -34,14 +34,17 @@ __title__="FreeCAD Site"
|
|||
__author__ = "Yorik van Havre"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
def makeSite(objectslist=None,name=translate("Arch","Site")):
|
||||
def makeSite(objectslist=None,baseobj=None,name=translate("Arch","Site")):
|
||||
'''makeBuilding(objectslist): creates a site including the
|
||||
objects from the given list.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
_Site(obj)
|
||||
_ViewProviderSite(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderSite(obj.ViewObject)
|
||||
if objectslist:
|
||||
obj.Group = objectslist
|
||||
if baseobj:
|
||||
obj.Terrain = baseobj
|
||||
return obj
|
||||
|
||||
class _CommandSite:
|
||||
|
|
|
@ -40,7 +40,8 @@ def makeSpace(objects=None,name=translate("Arch","Space")):
|
|||
selection objects as got from getSelectionEx(), or a list of tuples (object, subobjectname)"""
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Space(obj)
|
||||
_ViewProviderSpace(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderSpace(obj.ViewObject)
|
||||
if objects:
|
||||
if not isinstance(objects,list):
|
||||
objects = [objects]
|
||||
|
|
|
@ -36,15 +36,16 @@ else:
|
|||
return txt
|
||||
|
||||
|
||||
def makeStairs(base=None,length=None,width=None,height=None,steps=None,name=translate("Arch","Stairs")):
|
||||
"""makeStairs([base,length,width,height,steps]): creates a Stairs
|
||||
def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name=translate("Arch","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)
|
||||
_Stairs(obj)
|
||||
_ViewProviderStairs(obj.ViewObject)
|
||||
if base:
|
||||
obj.Base = base
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderStairs(obj.ViewObject)
|
||||
if baseobj:
|
||||
obj.Base = baseobj
|
||||
if length:
|
||||
obj.Length = length
|
||||
else:
|
||||
|
@ -80,7 +81,7 @@ class _CommandStairs:
|
|||
FreeCADGui.doCommand("import Arch")
|
||||
if len(FreeCADGui.Selection.getSelection()) == 1:
|
||||
n = FreeCADGui.Selection.getSelection()[0].Name
|
||||
FreeCADGui.doCommand("Arch.makeStairs(base=FreeCAD.ActiveDocument."+n+")")
|
||||
FreeCADGui.doCommand("Arch.makeStairs(baseobj=FreeCAD.ActiveDocument."+n+")")
|
||||
else:
|
||||
FreeCADGui.doCommand("Arch.makeStairs()")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
|
|
@ -295,7 +295,9 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name=translate
|
|||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Structure(obj)
|
||||
_ViewProviderStructure(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderStructure(obj.ViewObject)
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Structure")
|
||||
if baseobj:
|
||||
obj.Base = baseobj
|
||||
obj.Base.ViewObject.hide()
|
||||
|
@ -316,7 +318,6 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name=translate
|
|||
obj.Length = p.GetFloat("StructureLength",100)
|
||||
if height > length:
|
||||
obj.Role = "Column"
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Structure")
|
||||
return obj
|
||||
|
||||
def makeStructuralSystem(objects,axes,name=translate("Arch","StructuralSystem")):
|
||||
|
@ -329,12 +330,14 @@ def makeStructuralSystem(objects,axes,name=translate("Arch","StructuralSystem"))
|
|||
for o in objects:
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_StructuralSystem(obj)
|
||||
_ViewProviderStructuralSystem(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderStructuralSystem(obj.ViewObject)
|
||||
obj.Base = o
|
||||
obj.Axes = axes
|
||||
result.append(obj)
|
||||
o.ViewObject.hide()
|
||||
Draft.formatObject(obj,o)
|
||||
if FreeCAD.GuiUp:
|
||||
o.ViewObject.hide()
|
||||
Draft.formatObject(obj,o)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
if len(result) == 1:
|
||||
return result[0]
|
||||
|
@ -353,7 +356,8 @@ def makeProfile(W=46,H=80,tw=3.8,tf=5.2,name="Profile"):
|
|||
obj.Height = H
|
||||
obj.WebThickness = tw
|
||||
obj.FlangeThickness = tf
|
||||
Draft._ViewProviderDraft(obj.ViewObject)
|
||||
if FreeCAD.GuiUp:
|
||||
Draft._ViewProviderDraft(obj.ViewObject)
|
||||
return obj
|
||||
|
||||
class _CommandStructure:
|
||||
|
|
|
@ -49,7 +49,6 @@ def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face
|
|||
if FreeCAD.GuiUp:
|
||||
_ViewProviderWall(obj.ViewObject)
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Wall")
|
||||
|
||||
if baseobj:
|
||||
obj.Base = baseobj
|
||||
if face:
|
||||
|
|
|
@ -51,11 +51,12 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name=translate("Ar
|
|||
if Draft.getType(baseobj) == "Window":
|
||||
obj = Draft.clone(baseobj)
|
||||
return obj
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Window(obj)
|
||||
_ViewProviderWindow(obj.ViewObject)
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj.ViewObject.Transparency=p.GetInt("WindowTransparency",85)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderWindow(obj.ViewObject)
|
||||
obj.ViewObject.Transparency=p.GetInt("WindowTransparency",85)
|
||||
if width:
|
||||
obj.Width = width
|
||||
if height:
|
||||
|
@ -67,7 +68,7 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name=translate("Ar
|
|||
obj.WindowParts = parts
|
||||
else:
|
||||
if baseobj:
|
||||
if baseobj.isDerivedFrom("Part::Feature"):
|
||||
if baseobj.isDerivedFrom("Part::Part2DObject"):
|
||||
if baseobj.Shape.Wires:
|
||||
i = 0
|
||||
ws = ''
|
||||
|
@ -77,7 +78,7 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name=translate("Ar
|
|||
ws += "Wire" + str(i)
|
||||
i += 1
|
||||
obj.WindowParts = ["Default","Frame",ws,"1","0"]
|
||||
if obj.Base:
|
||||
if obj.Base and FreeCAD.GuiUp:
|
||||
obj.Base.ViewObject.DisplayMode = "Wireframe"
|
||||
obj.Base.ViewObject.hide()
|
||||
return obj
|
||||
|
@ -673,7 +674,10 @@ class _Window(ArchComponent.Component):
|
|||
if not DraftGeomUtils.isNull(pl):
|
||||
base.Placement = pl
|
||||
elif not obj.WindowParts:
|
||||
pass
|
||||
if not obj.Base.Shape.isNull():
|
||||
base = obj.Base.Shape.copy()
|
||||
if not DraftGeomUtils.isNull(pl):
|
||||
base.Placement = base.Placement.multiply(pl)
|
||||
else:
|
||||
print "Arch: Bad formatting of window parts definitions"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user