Draft: fix regression in Pattern display (add find_coin_node_by_name function)
Adapted existing code attribution and added a new function to find a node by name.
This commit is contained in:
@@ -939,14 +939,25 @@ def get_bbox(obj, debug=False):
|
||||
return App.BoundBox(xmin, ymin, zmin, xmax, ymax, zmax)
|
||||
|
||||
|
||||
# Code by Yorik van Havre.
|
||||
# Code by Yorik van Havre (adapted).
|
||||
def find_coin_node(parent, nodetype):
|
||||
if not hasattr(parent, "getNumChildren"):
|
||||
return None
|
||||
for i in range(parent.getNumChildren()):
|
||||
if isinstance(parent.getChild(i), nodetype):
|
||||
return parent.getChild(i)
|
||||
return None
|
||||
|
||||
|
||||
def find_coin_node_by_name(parent, name):
|
||||
if not hasattr(parent, "getNumChildren"):
|
||||
return None
|
||||
for i in range(parent.getNumChildren()):
|
||||
if parent.getChild(i).getName() == name:
|
||||
return parent.getChild(i)
|
||||
return None
|
||||
|
||||
|
||||
# Code by Chris Hennes (chennes).
|
||||
# See https://forum.freecad.org/viewtopic.php?p=656362#p656362.
|
||||
# Used to fix https://github.com/FreeCAD/FreeCAD/issues/10469.
|
||||
|
||||
Reference in New Issue
Block a user