Arch: Added utility command to create an undefined Arch component clone of an object

This commit is contained in:
Yorik van Havre 2016-12-30 18:07:13 -02:00
parent b16fbcd4ee
commit ac598f5104
5 changed files with 224 additions and 8 deletions

View File

@ -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())

View File

@ -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):

View File

@ -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",

View File

@ -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>

View File

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2980"
sodipodi:version="0.32"
inkscape:version="0.91 r13725"
sodipodi:docname="Arch_Component_Clone.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs2982">
<linearGradient
id="linearGradient3864">
<stop
id="stop3866"
offset="0"
style="stop-color:#71b2f8;stop-opacity:1;" />
<stop
id="stop3868"
offset="1"
style="stop-color:#002795;stop-opacity:1;" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective2988" />
<linearGradient
gradientTransform="matrix(1,0,0,0.96889279,-1.5,1.0452469)"
gradientUnits="userSpaceOnUse"
y2="12.160761"
x2="30.113636"
y1="61.410763"
x1="31.125395"
id="linearGradient3866"
xlink:href="#linearGradient3860"
inkscape:collect="always" />
<linearGradient
id="linearGradient3860">
<stop
id="stop3862"
offset="0"
style="stop-color:#003e8d;stop-opacity:1" />
<stop
id="stop3864"
offset="1"
style="stop-color:#66bbff;stop-opacity:1" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.5"
inkscape:cx="-28.181818"
inkscape:cy="32.181818"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1051"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata2985">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
id="g3845"
transform="matrix(0.9624254,0,0,0.9624254,-63.864287,-126.15825)"
style="fill:#ffffff;fill-opacity:1">
<path
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:bevel;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 96.18444,141.44968 L 76.37003,148.62889 L 105.80493,152.60098 L 105.08136,188.72763 L 122.34017,177.78375 L 122.91604,143.3989 L 96.18444,141.44968 z"
id="path3823"
sodipodi:nodetypes="ccccccc" />
<path
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:bevel;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 75.57941,148.6589 L 106.28825,152.02452 L 106.28825,188.50171 L 75.16442,183.43692 L 75.57941,148.6589 z"
id="path3825"
sodipodi:nodetypes="ccccc" />
<path
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 106.05435,152.06948 L 122.78033,143.66068"
id="path3827" />
</g>
<g
inkscape:label="Layer 1"
id="layer1-3"
transform="matrix(0.54817793,0,0,0.54817793,0.25846939,28.471874)"
style="stroke-width:5.4726758;stroke-miterlimit:4;stroke-dasharray:none">
<path
sodipodi:nodetypes="csscssscssscsscc"
inkscape:connector-curvature="0"
d="m 27.954545,56.184055 c 0,0 2,-0.176162 -4,2.466272 -6,2.642435 -10.318182,-1.321216 -12.5,-2.99476 C 9.33773,54.031884 7.8181813,50.282617 7.7727273,47.375939 5.5909091,47.023613 3.0454545,41.738744 4.1363636,39.096309 5.2272727,36.453875 8.681818,35.220738 10.318182,29.935868 c 1.636363,-5.28487 1.272727,-14.269148 1.636363,-15.678446 0.363637,-1.4093 2.181819,-11.8028765 19.41497,-11.8028762 17.233152,2e-7 19.051334,10.3935772 19.414971,11.8028772 0.363636,1.409298 0,10.393576 1.636363,15.678446 1.636364,5.28487 5.090909,6.518007 6.181818,9.160441 1.09091,2.642435 -1.454545,7.927304 -3.636363,8.27963 -0.04545,2.906678 -1.565003,6.655945 -3.681818,8.279628 -2.181818,1.673544 -6.5,5.637195 -12.5,2.99476 -6,-2.642434 -4,-2.466272 -4,-2.466272 z"
style="fill:url(#linearGradient3866);fill-opacity:1;stroke:#000000;stroke-width:5.4726758;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path3004-1" />
<path
inkscape:connector-curvature="0"
id="path3794"
d="M 14.570609,23.068836 27.55566,22.570573 c 0,0 -0.514259,2.740444 -3.728381,4.608927 -3.214121,1.868484 -6.299678,1.743918 -6.299678,1.743918 0,0 -0.77139,-0.249131 -1.928473,-2.615877 -1.157084,-2.366746 -1.028519,-3.238705 -1.028519,-3.238705 z"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.82422519;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3794-0"
d="M 47.55141,23.068836 34.566359,22.570573 c 0,0 0.514259,2.740444 3.728381,4.608927 3.214121,1.868484 6.299678,1.743918 6.299678,1.743918 0,0 0.77139,-0.249131 1.928473,-2.615877 1.157084,-2.366746 1.028519,-3.238705 1.028519,-3.238705 z"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.82422519;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cssscsssc"
inkscape:connector-curvature="0"
id="path3814"
d="m 17.141906,44.244984 c 0,0 3.406969,-1.121091 5.978266,-3.363271 2.571298,-2.24218 3.406969,-4.982623 7.778175,-4.982623 4.371205,0 5.27116,3.051856 8.356716,5.543168 2.985945,2.410884 5.656855,2.802726 5.656855,2.802726 0,0 -4.178359,0.622828 -7.135351,-1.121091 -2.956991,-1.743917 -2.571297,-4.048381 -6.813937,-3.923816 -4.242641,0.124566 -4.949747,2.67816 -8.035304,3.923816 -3.085557,1.245657 -5.78542,1.121091 -5.78542,1.121091 z"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.82422519;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3816"
d="m 11.904233,31.329198 3.14619,3.832344 -2.409091,3.170922 c 0,0 -0.590909,-1.101014 -0.681819,-2.818597 -0.09091,-1.717583 -0.05528,-4.184669 -0.05528,-4.184669 z"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.82422519;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
inkscape:transform-center-x="-1.5454545"
inkscape:connector-curvature="0"
id="path3816-2"
d="m 49.402211,29.670811 -3.14619,3.832344 2.409091,3.170922 c 0,0 0.590909,-1.101014 0.681819,-2.818597 0.09091,-1.717583 0.05528,-4.184669 0.05528,-4.184669 z"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.82422519;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<circle
transform="matrix(1,0,0,0.96889279,0.1363636,-0.54021403)"
id="path3836"
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.85327804;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
cx="20.227272"
cy="55.409092"
r="2.0454545" />
<circle
transform="matrix(1,0,0,0.96889279,21.636364,-0.93658032)"
id="path3836-8"
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.85327804;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
cx="20.227272"
cy="55.409092"
r="2.0454545" />
<path
sodipodi:nodetypes="cssscc"
inkscape:connector-curvature="0"
id="path3856"
d="m 28.136364,56.184055 c 0,0 -2.272728,0 -2.272728,-2.202029 0,-2.20203 1.911635,-6.469935 4.722705,-6.429925 3.130346,0.04456 4.786987,4.139814 4.877896,6.429925 0.09091,2.29011 -1.873328,2.378191 -1.873328,2.378191 z"
style="fill:#565656;fill-opacity:1;stroke:#000000;stroke-width:1.82422519;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3858"
d="m 8.929825,20.406247 c 0,0 13.081475,-1.712777 22.804193,-1.370221 9.722719,0.342555 21.389981,1.541499 21.389981,1.541499"
style="fill:none;stroke:#000000;stroke-width:1.82422519;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 10 KiB