Merge branch 'master' into logari81/sketcher
This commit is contained in:
commit
f201ea0b82
|
@ -59,7 +59,13 @@ class _CommandAxis:
|
|||
def Activated(self):
|
||||
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Axis")))
|
||||
FreeCADGui.doCommand("import Arch")
|
||||
FreeCADGui.doCommand("Arch.makeAxis()")
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
st = Draft.getObjectsOfType(sel,"Structure")
|
||||
if st:
|
||||
FreeCADGui.doCommand("axe = Arch.makeAxis()")
|
||||
FreeCADGui.doCommand("Arch.makeStructuralSystem(" + ArchCommands.getStringList(st) + ",[axe])")
|
||||
else:
|
||||
FreeCADGui.doCommand("Arch.makeAxis()")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
||||
class _Axis:
|
||||
|
|
|
@ -32,6 +32,17 @@ __url__ = "http://free-cad.sourceforge.net"
|
|||
|
||||
# module functions ###############################################
|
||||
|
||||
def getStringList(objects):
|
||||
'''getStringList(objects): returns a string defining a list
|
||||
of objects'''
|
||||
result = "["
|
||||
for o in objects:
|
||||
if len(result) > 1:
|
||||
result += ","
|
||||
result += "FreeCAD.ActiveDocument." + o.Name
|
||||
result += "]"
|
||||
return result
|
||||
|
||||
def addComponents(objectsList,host):
|
||||
'''addComponents(objectsList,hostObject): adds the given object or the objects
|
||||
from the given list as components to the given host Object. Use this for
|
||||
|
@ -53,11 +64,18 @@ def addComponents(objectsList,host):
|
|||
host.Group = c
|
||||
elif tp in ["Wall","Structure"]:
|
||||
a = host.Additions
|
||||
if hasattr(host,"Axes"):
|
||||
x = host.Axes
|
||||
for o in objectsList:
|
||||
if not o in a:
|
||||
if Draft.getType(o) == "Axis":
|
||||
if not o in x:
|
||||
x.append(o)
|
||||
elif not o in a:
|
||||
if hasattr(o,"Shape"):
|
||||
a.append(o)
|
||||
host.Additions = a
|
||||
if hasattr(host,"Axes"):
|
||||
host.Axes = x
|
||||
elif tp in ["SectionPlane"]:
|
||||
a = host.Objects
|
||||
for o in objectsList:
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import FreeCAD,FreeCADGui,Draft,ArchComponent,DraftVecUtils
|
||||
import FreeCAD,FreeCADGui,Draft,ArchComponent,DraftVecUtils,ArchCommands
|
||||
from FreeCAD import Vector
|
||||
from PyQt4 import QtCore
|
||||
from DraftTools import translate
|
||||
|
@ -52,6 +52,18 @@ def makeStructure(baseobj=None,length=1,width=1,height=1,name=str(translate("Arc
|
|||
obj.ViewObject.ShapeColor = (r,g,b,1.0)
|
||||
return obj
|
||||
|
||||
def makeStructuralSystem(objects,axes):
|
||||
'''makeStructuralSystem(objects,axes): makes a structural system
|
||||
based on the given objects and axes'''
|
||||
result = []
|
||||
if objects and axes:
|
||||
for o in objects:
|
||||
s = makeStructure(o)
|
||||
s.Axes = axes
|
||||
result.append(s)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
return result
|
||||
|
||||
class _CommandStructure:
|
||||
"the Arch Structure command definition"
|
||||
def GetResources(self):
|
||||
|
@ -65,8 +77,15 @@ class _CommandStructure:
|
|||
FreeCADGui.doCommand("import Arch")
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if sel:
|
||||
for obj in sel:
|
||||
FreeCADGui.doCommand("Arch.makeStructure(FreeCAD.ActiveDocument."+obj.Name+")")
|
||||
# if selection contains structs and axes, make a system
|
||||
st = Draft.getObjectsOfType(sel,"Structure")
|
||||
ax = Draft.getObjectsOfType(sel,"Axis")
|
||||
if st and ax:
|
||||
FreeCADGui.doCommand("Arch.makeStructuralSystem(" + ArchCommands.getStringList(st) + "," + ArchCommands.getStringList(ax) + ")")
|
||||
else:
|
||||
# else, do normal structs
|
||||
for obj in sel:
|
||||
FreeCADGui.doCommand("Arch.makeStructure(FreeCAD.ActiveDocument." + obj.Name + ")")
|
||||
else:
|
||||
FreeCADGui.doCommand("Arch.makeStructure()")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
|
|
@ -58,27 +58,36 @@ class ArchWorkbench(Workbench):
|
|||
|
||||
def Initialize(self):
|
||||
import DraftTools,DraftGui,Arch_rc,Arch
|
||||
|
||||
# arch tools
|
||||
self.archtools = ["Arch_Wall","Arch_Structure",
|
||||
"Arch_Floor","Arch_Building","Arch_Site",
|
||||
"Arch_Window","Arch_Roof","Arch_Axis",
|
||||
"Arch_SectionPlane","Arch_Add","Arch_Remove"]
|
||||
self.drafttools = ["Draft_Line","Draft_Wire","Draft_Rectangle",
|
||||
"Draft_Polygon","Draft_Arc",
|
||||
"Draft_Circle","Draft_Dimension",
|
||||
"Draft_Move","Draft_Rotate",
|
||||
"Draft_Offset","Draft_Upgrade",
|
||||
"Draft_Downgrade","Draft_Trimex"]
|
||||
self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode",
|
||||
"Draft_AddToGroup","Draft_SelectGroup",
|
||||
"Draft_SelectPlane","Draft_ToggleSnap",
|
||||
"Draft_ShowSnapBar","Draft_ToggleGrid"]
|
||||
self.meshtools = ["Arch_SplitMesh","Arch_MeshToShape",
|
||||
"Arch_SelectNonSolidMeshes","Arch_RemoveShape"]
|
||||
|
||||
# draft tools
|
||||
self.drafttools = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc",
|
||||
"Draft_Polygon","Draft_Rectangle", "Draft_Text",
|
||||
"Draft_Dimension", "Draft_BSpline","Draft_Point"]
|
||||
self.draftmodtools = ["Draft_Move","Draft_Rotate","Draft_Offset",
|
||||
"Draft_Trimex", "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale",
|
||||
"Draft_Drawing","Draft_Edit","Draft_WireToBSpline","Draft_AddPoint",
|
||||
"Draft_DelPoint","Draft_Shape2DView","Draft_Draft2Sketch","Draft_Array",
|
||||
"Draft_Clone"]
|
||||
self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup",
|
||||
"Draft_SelectGroup","Draft_SelectPlane","Draft_ToggleSnap",
|
||||
"Draft_ShowSnapBar","Draft_ToggleGrid","Draft_UndoLine",
|
||||
"Draft_FinishLine","Draft_CloseLine"]
|
||||
|
||||
self.appendToolbar(str(DraftTools.translate("arch","Arch tools")),self.archtools)
|
||||
self.appendToolbar(str(DraftTools.translate("arch","Draft tools")),self.drafttools)
|
||||
self.appendToolbar(str(DraftTools.translate("arch","Draft mod tools")),self.draftmodtools)
|
||||
self.appendMenu([str(DraftTools.translate("arch","&Architecture")),str(DraftTools.translate("arch","Conversion Tools"))],self.meshtools)
|
||||
self.appendMenu(str(DraftTools.translate("arch","&Architecture")),self.archtools)
|
||||
self.appendMenu(str(DraftTools.translate("arch","&Draft")),self.drafttools+self.draftcontexttools)
|
||||
self.appendMenu(str(DraftTools.translate("arch","&Draft")),self.drafttools+self.draftmodtools)
|
||||
self.appendMenu([str(DraftTools.translate("arch","&Draft")),str(DraftTools.translate("arch","Context Tools"))],self.draftcontexttools)
|
||||
FreeCADGui.addIconPath(":/icons")
|
||||
FreeCADGui.addLanguagePath(":/translations")
|
||||
FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
|
||||
|
|
|
@ -173,6 +173,15 @@ def getType(obj):
|
|||
return "Group"
|
||||
return "Unknown"
|
||||
|
||||
def getObjectsOfType(objectslist,typ):
|
||||
"""getObjectsOfType(objectslist,typ): returns a list of objects of type "typ" found
|
||||
in the given object list"""
|
||||
objs = []
|
||||
for o in objectslist:
|
||||
if getType(o) == typ:
|
||||
objs.append(o)
|
||||
return objs
|
||||
|
||||
def get3DView():
|
||||
"get3DView(): returns the current view if it is 3D, or the first 3D view found, or None"
|
||||
v = FreeCADGui.ActiveDocument.ActiveView
|
||||
|
|
Loading…
Reference in New Issue
Block a user