Arch: Added utility command to create an undefined Arch component clone of an object
This commit is contained in:
@@ -212,6 +212,13 @@ def makeComponent(baseobj=None,name="Component",delete=False):
|
||||
elif isinstance(baseobj,Part.Shape):
|
||||
obj.Shape = baseobj
|
||||
return obj
|
||||
|
||||
def cloneComponent(obj):
|
||||
'''cloneComponent(obj): Creates a clone of an object as an undefined component'''
|
||||
c = makeComponent()
|
||||
c.CloneOf = obj
|
||||
c.Placement = obj.Placement
|
||||
c.Label = obj.Label
|
||||
|
||||
def setAsSubcomponent(obj):
|
||||
'''Sets the given object properly to become a subcomponent (addition, subtraction)
|
||||
@@ -1283,6 +1290,30 @@ class _CommandComponent:
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
class _CommandCloneComponent:
|
||||
"the Arch Clone Component command definition"
|
||||
def GetResources(self):
|
||||
return {'Pixmap' : 'Arch_Component_Clone',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_CloneComponent","Clone component"),
|
||||
'Accel': "C, C",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_CloneComponent","Clones an object as an undefined architectural component")}
|
||||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
def Activated(self):
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if sel:
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Component"))
|
||||
FreeCADGui.addModule("Arch")
|
||||
FreeCADGui.Control.closeDialog()
|
||||
for o in sel:
|
||||
FreeCADGui.doCommand("Arch.cloneComponent(FreeCAD.ActiveDocument."+o.Name+")")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
def makeIfcSpreadsheet(archobj=None):
|
||||
ifc_container = None
|
||||
for obj in FreeCAD.ActiveDocument.Objects :
|
||||
@@ -1371,5 +1402,6 @@ if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Arch_Survey',_CommandSurvey())
|
||||
FreeCADGui.addCommand('Arch_ToggleIfcBrepFlag',_ToggleIfcBrepFlag())
|
||||
FreeCADGui.addCommand('Arch_Component',_CommandComponent())
|
||||
FreeCADGui.addCommand('Arch_CloneComponent',_CommandCloneComponent())
|
||||
FreeCADGui.addCommand('Arch_IfcSpreadsheet',_CommandIfcSpreadsheet())
|
||||
FreeCADGui.addCommand('Arch_ToggleSubs',_ToggleSubs())
|
||||
|
||||
@@ -361,10 +361,7 @@ class Component:
|
||||
pl = obj.Placement
|
||||
obj.Shape = obj.CloneOf.Shape.copy()
|
||||
obj.Placement = pl
|
||||
if hasattr(obj,"BaseMaterial"):
|
||||
if hasattr(obj.CloneOf,"BaseMaterial"):
|
||||
obj.BaseMaterial = obj.CloneOf.BaseMaterial
|
||||
for prop in ["Length","Width","Height","Thickness","Area","PerimeterLength","HorizontalArea","VerticalArea"]:
|
||||
for prop in ["Length","Width","Height","Thickness","Area","PerimeterLength","HorizontalArea","VerticalArea","BaseMaterial","IfcAttributes"]:
|
||||
if hasattr(obj,prop) and hasattr(obj.CloneOf,prop):
|
||||
setattr(obj,prop,getattr(obj.CloneOf,prop))
|
||||
return True
|
||||
@@ -632,9 +629,9 @@ class ViewProviderComponent:
|
||||
#print obj.Name," : updating ",prop
|
||||
if prop == "BaseMaterial":
|
||||
if obj.BaseMaterial:
|
||||
if 'Color' in obj.BaseMaterial.Material:
|
||||
if "(" in obj.BaseMaterial.Material['Color']:
|
||||
c = tuple([float(f) for f in obj.BaseMaterial.Material['Color'].strip("()").split(",")])
|
||||
if 'DiffuseColor' in obj.BaseMaterial.Material:
|
||||
if "(" in obj.BaseMaterial.Material['DiffuseColor']:
|
||||
c = tuple([float(f) for f in obj.BaseMaterial.Material['DiffuseColor'].strip("()").split(",")])
|
||||
if obj.ViewObject:
|
||||
obj.ViewObject.ShapeColor = c
|
||||
elif prop == "Shape":
|
||||
@@ -654,6 +651,10 @@ class ViewProviderComponent:
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
if hasattr(self,"Object"):
|
||||
if hasattr(self.Object,"CloneOf"):
|
||||
if self.Object.CloneOf:
|
||||
return ":/icons/Arch_Component_Clone.svg"
|
||||
return ":/icons/Arch_Component.svg"
|
||||
|
||||
def onChanged(self,vobj,prop):
|
||||
|
||||
@@ -40,7 +40,7 @@ class ArchWorkbench(Workbench):
|
||||
"Arch_PanelTools","Arch_Equipment",
|
||||
"Arch_Frame","Arch_Material","Arch_Schedule","Arch_PipeTools",
|
||||
"Arch_CutPlane","Arch_Add","Arch_Remove","Arch_Survey"]
|
||||
self.utilities = ["Arch_Component","Arch_SplitMesh","Arch_MeshToShape",
|
||||
self.utilities = ["Arch_Component","Arch_CloneComponent","Arch_SplitMesh","Arch_MeshToShape",
|
||||
"Arch_SelectNonSolidMeshes","Arch_RemoveShape",
|
||||
"Arch_CloseHoles","Arch_MergeWalls","Arch_Check",
|
||||
"Arch_IfcExplorer","Arch_ToggleIfcBrepFlag","Arch_3Views",
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
<file>icons/Arch_Bimserver.svg</file>
|
||||
<file>icons/Git.svg</file>
|
||||
<file>icons/Arch_Component.svg</file>
|
||||
<file>icons/Arch_Component_Clone.svg</file>
|
||||
<file>icons/Arch_Material.svg</file>
|
||||
<file>icons/Arch_Material_Group.svg</file>
|
||||
<file>icons/Arch_Schedule.svg</file>
|
||||
|
||||
182
src/Mod/Arch/Resources/icons/Arch_Component_Clone.svg
Normal file
182
src/Mod/Arch/Resources/icons/Arch_Component_Clone.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 10 KiB |
Reference in New Issue
Block a user