Arch: Added Arch/Utilities/Toggle Subcomponent Display command
This commit is contained in:
@@ -66,6 +66,9 @@ def getDefaultColor(objectType):
|
|||||||
c = p.GetUnsigned("RebarColor",3111475967)
|
c = p.GetUnsigned("RebarColor",3111475967)
|
||||||
elif objectType == "Panel":
|
elif objectType == "Panel":
|
||||||
c = p.GetUnsigned("PanelColor",3416289279)
|
c = p.GetUnsigned("PanelColor",3416289279)
|
||||||
|
elif objectType == "Construction":
|
||||||
|
c = Draft.getParam("constructioncolor",746455039)
|
||||||
|
transparency = 0.80
|
||||||
else:
|
else:
|
||||||
c = p.GetUnsigned("WindowsColor",810781695)
|
c = p.GetUnsigned("WindowsColor",810781695)
|
||||||
r = float((c>>24)&0xFF)/255.0
|
r = float((c>>24)&0xFF)/255.0
|
||||||
@@ -85,6 +88,7 @@ def addComponents(objectsList,host):
|
|||||||
c = host.Group
|
c = host.Group
|
||||||
for o in objectsList:
|
for o in objectsList:
|
||||||
if not o in c:
|
if not o in c:
|
||||||
|
setAsSubcomponent(o)
|
||||||
c.append(o)
|
c.append(o)
|
||||||
host.Group = c
|
host.Group = c
|
||||||
elif hostType in ["Wall","Structure","Window","Roof","Stairs","StructuralSystem","Panel"]:
|
elif hostType in ["Wall","Structure","Window","Roof","Stairs","StructuralSystem","Panel"]:
|
||||||
@@ -97,12 +101,15 @@ def addComponents(objectsList,host):
|
|||||||
if DraftGeomUtils.isValidPath(o.Shape) and (hostType == "Structure"):
|
if DraftGeomUtils.isValidPath(o.Shape) and (hostType == "Structure"):
|
||||||
if o.Support == host:
|
if o.Support == host:
|
||||||
o.Support = None
|
o.Support = None
|
||||||
|
setAsSubcomponent(o)
|
||||||
host.Tool = o
|
host.Tool = o
|
||||||
elif Draft.getType(o) == "Axis":
|
elif Draft.getType(o) == "Axis":
|
||||||
if not o in x:
|
if not o in x:
|
||||||
|
setAsSubcomponent(o)
|
||||||
x.append(o)
|
x.append(o)
|
||||||
elif not o in a:
|
elif not o in a:
|
||||||
if hasattr(o,"Shape"):
|
if hasattr(o,"Shape"):
|
||||||
|
setAsSubcomponent(o)
|
||||||
a.append(o)
|
a.append(o)
|
||||||
host.Additions = a
|
host.Additions = a
|
||||||
if hasattr(host,"Axes"):
|
if hasattr(host,"Axes"):
|
||||||
@@ -111,12 +118,14 @@ def addComponents(objectsList,host):
|
|||||||
a = host.Objects
|
a = host.Objects
|
||||||
for o in objectsList:
|
for o in objectsList:
|
||||||
if not o in a:
|
if not o in a:
|
||||||
|
setAsSubcomponent(o)
|
||||||
a.append(o)
|
a.append(o)
|
||||||
host.Objects = a
|
host.Objects = a
|
||||||
elif host.isDerivedFrom("App::DocumentObjectGroup"):
|
elif host.isDerivedFrom("App::DocumentObjectGroup"):
|
||||||
c = host.Group
|
c = host.Group
|
||||||
for o in objectsList:
|
for o in objectsList:
|
||||||
if not o in c:
|
if not o in c:
|
||||||
|
setAsSubcomponent(o)
|
||||||
c.append(o)
|
c.append(o)
|
||||||
host.Group = c
|
host.Group = c
|
||||||
|
|
||||||
@@ -141,6 +150,7 @@ def removeComponents(objectsList,host=None):
|
|||||||
s = host.Subtractions
|
s = host.Subtractions
|
||||||
for o in objectsList:
|
for o in objectsList:
|
||||||
if not o in s:
|
if not o in s:
|
||||||
|
setAsSubcomponent(o)
|
||||||
s.append(o)
|
s.append(o)
|
||||||
fixDAG(o)
|
fixDAG(o)
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
@@ -201,6 +211,17 @@ def makeComponent(baseobj=None,name="Component",delete=False):
|
|||||||
obj.Shape = baseobj
|
obj.Shape = baseobj
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
def setAsSubcomponent(obj):
|
||||||
|
'''Sets the given object properly to become a subcomponent (addition, subtraction)
|
||||||
|
of an Arch component'''
|
||||||
|
Draft.ungroup(obj)
|
||||||
|
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("applyConstructionStyle",True):
|
||||||
|
if FreeCAD.GuiUp:
|
||||||
|
color = getDefaultColor("Construction")
|
||||||
|
obj.ViewObject.LineColor = color
|
||||||
|
obj.ViewObject.ShapeColor = color
|
||||||
|
obj.ViewObject.Transparency = int(color[3]*100)
|
||||||
|
|
||||||
def fixDAG(obj):
|
def fixDAG(obj):
|
||||||
'''fixDAG(object): Fixes non-DAG problems in windows and rebars
|
'''fixDAG(object): Fixes non-DAG problems in windows and rebars
|
||||||
by removing supports and external geometry from underlying sketches'''
|
by removing supports and external geometry from underlying sketches'''
|
||||||
@@ -1275,6 +1296,32 @@ class _CommandIfcSpreadsheet:
|
|||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
|
|
||||||
|
|
||||||
|
class _ToggleSubcomponentDisplay:
|
||||||
|
"the Toggle SubcomponentDisplay command definition"
|
||||||
|
def GetResources(self):
|
||||||
|
return {'Pixmap' : 'Arch_ToggleSubcomponentDisplay',
|
||||||
|
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_ToggleSubcomponentDisplay","Toggle subcomponents"),
|
||||||
|
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_ToggleSubcomponentDisplay","Shows or hides the subcomponents of this object")}
|
||||||
|
|
||||||
|
def IsActive(self):
|
||||||
|
return bool(FreeCADGui.Selection.getSelection())
|
||||||
|
|
||||||
|
def Activated(self):
|
||||||
|
mode = None
|
||||||
|
for obj in FreeCADGui.Selection.getSelection():
|
||||||
|
if hasattr(obj, "Subtractions"):
|
||||||
|
for sub in obj.Subtractions:
|
||||||
|
if not (Draft.getType(sub) in ["Window","Roof"]):
|
||||||
|
if mode == None:
|
||||||
|
# take the first sub as base
|
||||||
|
mode = sub.ViewObject.isVisible()
|
||||||
|
if mode == True:
|
||||||
|
sub.ViewObject.hide()
|
||||||
|
else:
|
||||||
|
sub.ViewObject.show()
|
||||||
|
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
FreeCADGui.addCommand('Arch_Add',_CommandAdd())
|
FreeCADGui.addCommand('Arch_Add',_CommandAdd())
|
||||||
FreeCADGui.addCommand('Arch_Remove',_CommandRemove())
|
FreeCADGui.addCommand('Arch_Remove',_CommandRemove())
|
||||||
@@ -1289,3 +1336,4 @@ if FreeCAD.GuiUp:
|
|||||||
FreeCADGui.addCommand('Arch_ToggleIfcBrepFlag',_ToggleIfcBrepFlag())
|
FreeCADGui.addCommand('Arch_ToggleIfcBrepFlag',_ToggleIfcBrepFlag())
|
||||||
FreeCADGui.addCommand('Arch_Component',_CommandComponent())
|
FreeCADGui.addCommand('Arch_Component',_CommandComponent())
|
||||||
FreeCADGui.addCommand('Arch_IfcSpreadsheet',_CommandIfcSpreadsheet())
|
FreeCADGui.addCommand('Arch_IfcSpreadsheet',_CommandIfcSpreadsheet())
|
||||||
|
FreeCADGui.addCommand('Arch_ToggleSubcomponentDisplay',_ToggleSubcomponentDisplay())
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Roles = ['Undefined','Beam','Chimney','Column','Covering','Curtain Wall',
|
|||||||
'Member','Plate','Railing','Ramp','Ramp Flight','Rebar','Pile','Roof','Shading Device','Slab','Space',
|
'Member','Plate','Railing','Ramp','Ramp Flight','Rebar','Pile','Roof','Shading Device','Slab','Space',
|
||||||
'Stair','Stair Flight','Tendon','Wall','Wall Layer','Window']
|
'Stair','Stair Flight','Tendon','Wall','Wall Layer','Window']
|
||||||
|
|
||||||
import FreeCAD,Draft
|
import FreeCAD,Draft,ArchCommands
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
import FreeCADGui
|
import FreeCADGui
|
||||||
@@ -77,6 +77,7 @@ def addToComponent(compobject,addobject,mod=None):
|
|||||||
l.append(addobject)
|
l.append(addobject)
|
||||||
setattr(compobject,mod,l)
|
setattr(compobject,mod,l)
|
||||||
if mod != "Objects":
|
if mod != "Objects":
|
||||||
|
ArchCommands.setAsSubcomponent(addobject)
|
||||||
addobject.ViewObject.hide()
|
addobject.ViewObject.hide()
|
||||||
else:
|
else:
|
||||||
for a in attribs[:3]:
|
for a in attribs[:3]:
|
||||||
@@ -116,6 +117,7 @@ def removeFromComponent(compobject,subobject):
|
|||||||
l.append(subobject)
|
l.append(subobject)
|
||||||
compobject.Subtractions = l
|
compobject.Subtractions = l
|
||||||
if (Draft.getType(subobject) != "Window") and (not Draft.isClone(subobject,"Window",True)):
|
if (Draft.getType(subobject) != "Window") and (not Draft.isClone(subobject,"Window",True)):
|
||||||
|
ArchCommands.setAsSubcomponent(subobject)
|
||||||
subobject.ViewObject.hide()
|
subobject.ViewObject.hide()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class ArchWorkbench(Workbench):
|
|||||||
"Arch_SelectNonSolidMeshes","Arch_RemoveShape",
|
"Arch_SelectNonSolidMeshes","Arch_RemoveShape",
|
||||||
"Arch_CloseHoles","Arch_MergeWalls","Arch_Check",
|
"Arch_CloseHoles","Arch_MergeWalls","Arch_Check",
|
||||||
"Arch_IfcExplorer","Arch_ToggleIfcBrepFlag","Arch_3Views",
|
"Arch_IfcExplorer","Arch_ToggleIfcBrepFlag","Arch_3Views",
|
||||||
"Arch_Bimserver","Arch_Git","Arch_IfcSpreadsheet"]
|
"Arch_Bimserver","Arch_Git","Arch_IfcSpreadsheet","Arch_ToggleSubcomponentDisplay"]
|
||||||
|
|
||||||
# draft tools
|
# draft tools
|
||||||
self.drafttools = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",
|
self.drafttools = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",
|
||||||
|
|||||||
@@ -70,6 +70,7 @@
|
|||||||
<file>icons/Arch_Pipe.svg</file>
|
<file>icons/Arch_Pipe.svg</file>
|
||||||
<file>icons/Arch_Pipe_Tree.svg</file>
|
<file>icons/Arch_Pipe_Tree.svg</file>
|
||||||
<file>icons/Arch_PipeConnector.svg</file>
|
<file>icons/Arch_PipeConnector.svg</file>
|
||||||
|
<file>icons/Arch_ToggleSubcomponentDisplay.svg</file>
|
||||||
<file>ui/ParametersWindowDouble.svg</file>
|
<file>ui/ParametersWindowDouble.svg</file>
|
||||||
<file>ui/ParametersWindowSimple.svg</file>
|
<file>ui/ParametersWindowSimple.svg</file>
|
||||||
<file>ui/ParametersWindowFixed.svg</file>
|
<file>ui/ParametersWindowFixed.svg</file>
|
||||||
|
|||||||
473
src/Mod/Arch/Resources/icons/Arch_ToggleSubcomponentDisplay.svg
Normal file
473
src/Mod/Arch/Resources/icons/Arch_ToggleSubcomponentDisplay.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 20 KiB |
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>407</width>
|
<width>396</width>
|
||||||
<height>646</height>
|
<height>638</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -86,6 +86,26 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="Gui::PrefCheckBox" name="checkBox_7">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>If this is checked, when an object becomes Subtraction or Addition of an Arch object, it will receive the Draft Construction color.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Apply Draft construction style to subcomponents</string>
|
||||||
|
</property>
|
||||||
|
<property name="prefEntry" stdset="0">
|
||||||
|
<cstring>applyconstructionStyle</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="prefPath" stdset="0">
|
||||||
|
<cstring>Mod/Arch</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user