Avoid using getSubObject() to obtain shape

This commit is contained in:
Zheng, Lei 2020-07-02 09:17:24 +08:00
parent 9e34ecd1c0
commit 0acaa5e9c3
2 changed files with 11 additions and 4 deletions

View File

@ -626,8 +626,7 @@ class AsmElement(AsmBase):
if not subs[1]:
return False # no mapped element name
shape = linked.getSubObject(subs[0])
if not utils.getElement(shape, subs[1]):
if not utils.getElement(linked, subname):
return True
def fix(self):
@ -642,7 +641,7 @@ class AsmElement(AsmBase):
if not subs[1]:
raise RuntimeError('No mapped sub-element found')
shape = linked.getSubObject(subs[0])
shape = Part.getShape(linked,subs[0])
if utils.getElement(shape, subs[1]):
return

View File

@ -85,7 +85,7 @@ def isLine(param):
return isinstance(param,(Part.Line,Part.LineSegment))
def deduceSelectedElement(obj,subname):
shape = obj.getSubObject(subname)
shape = getElementShape(obj, subname)
if not shape:
return
count = shape.countElement('Face')
@ -207,6 +207,14 @@ def isElement(obj):
def getElement(shape, element):
res = None
if not isinstance(shape, Part.Shape):
try:
res = getElementShape(shape, element)
if res and not res.isNull():
return res
except Exception:
return
try:
res = shape.getElement(element, True)
except TypeError: