Arch: fixed behaviour of clones of windows - fixes #1841
This commit is contained in:
parent
3db987d9b7
commit
9b9526e4cc
|
@ -114,7 +114,7 @@ def removeFromComponent(compobject,subobject):
|
||||||
l = compobject.Subtractions
|
l = compobject.Subtractions
|
||||||
l.append(subobject)
|
l.append(subobject)
|
||||||
compobject.Subtractions = l
|
compobject.Subtractions = l
|
||||||
if Draft.getType(subobject) != "Window":
|
if (Draft.getType(subobject) != "Window") and (not Draft.isClone(subobject,"Window",True)):
|
||||||
subobject.ViewObject.hide()
|
subobject.ViewObject.hide()
|
||||||
|
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ class Component:
|
||||||
if prop in ["Additions","Subtractions"]:
|
if prop in ["Additions","Subtractions"]:
|
||||||
if hasattr(obj,prop):
|
if hasattr(obj,prop):
|
||||||
for o in getattr(obj,prop):
|
for o in getattr(obj,prop):
|
||||||
if Draft.getType(o) != "Window":
|
if (Draft.getType(o) != "Window") and (not Draft.isClone(o,"Window",True)):
|
||||||
if (Draft.getType(obj) == "Wall"):
|
if (Draft.getType(obj) == "Wall"):
|
||||||
if (Draft.getType(o) == "Roof"):
|
if (Draft.getType(o) == "Roof"):
|
||||||
continue
|
continue
|
||||||
|
@ -549,11 +549,11 @@ class Component:
|
||||||
add.Placement = add.Placement.multiply(placement)
|
add.Placement = add.Placement.multiply(placement)
|
||||||
base = base.fuse(add)
|
base = base.fuse(add)
|
||||||
|
|
||||||
elif (Draft.getType(o) == "Window") or (Draft.isClone(o,"Window")):
|
elif (Draft.getType(o) == "Window") or (Draft.isClone(o,"Window",True)):
|
||||||
f = o.Proxy.getSubVolume(o)
|
f = o.Proxy.getSubVolume(o)
|
||||||
if f:
|
if f:
|
||||||
if base.Solids and f.Solids:
|
if base.Solids and f.Solids:
|
||||||
if placemen:
|
if placement:
|
||||||
f.Placement = f.Placement.multiply(placement)
|
f.Placement = f.Placement.multiply(placement)
|
||||||
base = base.cut(f)
|
base = base.cut(f)
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ class Component:
|
||||||
base = None
|
base = None
|
||||||
|
|
||||||
if base:
|
if base:
|
||||||
if (Draft.getType(o) == "Window") or (Draft.isClone(o,"Window")):
|
if (Draft.getType(o) == "Window") or (Draft.isClone(o,"Window",True)):
|
||||||
# windows can be additions or subtractions, treated the same way
|
# windows can be additions or subtractions, treated the same way
|
||||||
f = o.Proxy.getSubVolume(o)
|
f = o.Proxy.getSubVolume(o)
|
||||||
if f:
|
if f:
|
||||||
|
@ -645,7 +645,7 @@ class ViewProviderComponent:
|
||||||
def onChanged(self,vobj,prop):
|
def onChanged(self,vobj,prop):
|
||||||
if prop == "Visibility":
|
if prop == "Visibility":
|
||||||
for obj in vobj.Object.Additions+vobj.Object.Subtractions:
|
for obj in vobj.Object.Additions+vobj.Object.Subtractions:
|
||||||
if Draft.getType(obj) == "Window":
|
if (Draft.getType(obj) == "Window") or (Draft.isClone(obj,"Window",True)):
|
||||||
obj.ViewObject.Visibility = vobj.Visibility
|
obj.ViewObject.Visibility = vobj.Visibility
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -237,15 +237,18 @@ def get3DView():
|
||||||
return v[0]
|
return v[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def isClone(obj,objtype):
|
def isClone(obj,objtype,recursive=False):
|
||||||
"""isClone(obj,objtype): returns True if the given object is
|
"""isClone(obj,objtype,[recursive]): returns True if the given object is
|
||||||
a clone of an object of the given type"""
|
a clone of an object of the given type. If recursive is True, also check if
|
||||||
|
the clone is a clone of clone (of clone...) of the given type."""
|
||||||
if getType(obj) == "Clone":
|
if getType(obj) == "Clone":
|
||||||
if len(obj.Objects) == 1:
|
if len(obj.Objects) == 1:
|
||||||
if getType(obj.Objects[0]) == objtype:
|
if getType(obj.Objects[0]) == objtype:
|
||||||
return True
|
return True
|
||||||
|
elif recursive and (getType(obj.Objects[0]) == "Clone"):
|
||||||
|
return isClone(obj.Objects[0],objtype,recursive)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getGroupNames():
|
def getGroupNames():
|
||||||
"returns a list of existing groups in the document"
|
"returns a list of existing groups in the document"
|
||||||
glist = []
|
glist = []
|
||||||
|
@ -581,17 +584,19 @@ def getMovableChildren(objectslist,recursive=False):
|
||||||
recursive is True, all descendents are considered, otherwise only direct children.'''
|
recursive is True, all descendents are considered, otherwise only direct children.'''
|
||||||
added = []
|
added = []
|
||||||
for obj in objectslist:
|
for obj in objectslist:
|
||||||
children = obj.OutList
|
if getType(obj) != "Clone":
|
||||||
if hasattr(obj,"Proxy"):
|
# clones should never move their children
|
||||||
if obj.Proxy:
|
children = obj.OutList
|
||||||
if hasattr(obj.Proxy,"getSiblings"):
|
if hasattr(obj,"Proxy"):
|
||||||
children.extend(obj.Proxy.getSiblings(obj))
|
if obj.Proxy:
|
||||||
for child in children:
|
if hasattr(obj.Proxy,"getSiblings"):
|
||||||
if hasattr(child,"MoveWithHost"):
|
children.extend(obj.Proxy.getSiblings(obj))
|
||||||
if child.MoveWithHost:
|
for child in children:
|
||||||
added.append(child)
|
if hasattr(child,"MoveWithHost"):
|
||||||
if recursive:
|
if child.MoveWithHost:
|
||||||
added.extend(getMovableChildren(children))
|
added.append(child)
|
||||||
|
if recursive:
|
||||||
|
added.extend(getMovableChildren(children))
|
||||||
return added
|
return added
|
||||||
|
|
||||||
def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None, support=None):
|
def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None, support=None):
|
||||||
|
@ -4968,6 +4973,17 @@ class _Clone(_DraftObject):
|
||||||
obj.Shape = Part.makeCompound(shapes)
|
obj.Shape = Part.makeCompound(shapes)
|
||||||
if not DraftGeomUtils.isNull(pl):
|
if not DraftGeomUtils.isNull(pl):
|
||||||
obj.Placement = pl
|
obj.Placement = pl
|
||||||
|
|
||||||
|
def getSubVolume(self,obj,placement=None):
|
||||||
|
# this allows clones of arch windows to return a subvolume too
|
||||||
|
if obj.Objects:
|
||||||
|
if hasattr(obj.Objects[0],"Proxy"):
|
||||||
|
if hasattr(obj.Objects[0].Proxy,"getSubVolume"):
|
||||||
|
if not placement:
|
||||||
|
# clones must displace the original subvolume too
|
||||||
|
placement = obj.Placement
|
||||||
|
return obj.Objects[0].Proxy.getSubVolume(obj.Objects[0],placement)
|
||||||
|
return None
|
||||||
|
|
||||||
class _ViewProviderClone(_ViewProviderDraftAlt):
|
class _ViewProviderClone(_ViewProviderDraftAlt):
|
||||||
"a view provider that displays a Clone icon instead of a Draft icon"
|
"a view provider that displays a Clone icon instead of a Draft icon"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user