utils.getElementPos now returns center for all shapes
This commit is contained in:
parent
cc16b178bb
commit
8d8f910efd
10
utils.py
10
utils.py
|
@ -176,8 +176,8 @@ def getElementPos(obj):
|
||||||
if face:
|
if face:
|
||||||
surface = face.Surface
|
surface = face.Surface
|
||||||
if str(surface) == '<Plane object>':
|
if str(surface) == '<Plane object>':
|
||||||
# pos = face.BoundBox.Center
|
pos = face.BoundBox.Center
|
||||||
pos = surface.Position
|
# pos = surface.Position
|
||||||
elif all( hasattr(surface,a) for a in ['Axis','Center','Radius'] ):
|
elif all( hasattr(surface,a) for a in ['Axis','Center','Radius'] ):
|
||||||
pos = surface.Center
|
pos = surface.Center
|
||||||
elif str(surface).startswith('<SurfaceOfRevolution'):
|
elif str(surface).startswith('<SurfaceOfRevolution'):
|
||||||
|
@ -197,7 +197,8 @@ def getElementPos(obj):
|
||||||
edge = getElement(obj,Part.Edge)
|
edge = getElement(obj,Part.Edge)
|
||||||
if edge:
|
if edge:
|
||||||
if isLine(edge.Curve):
|
if isLine(edge.Curve):
|
||||||
pos = edge.Vertexes[-1].Point
|
# pos = edge.Vertexes[-1].Point
|
||||||
|
pos = (edge.Vertexes[0].Point+edge.Vertexes[1].Point)*0.5
|
||||||
elif hasattr( edge.Curve, 'Center'): #circular curve
|
elif hasattr( edge.Curve, 'Center'): #circular curve
|
||||||
pos = edge.Curve.Center
|
pos = edge.Curve.Center
|
||||||
else:
|
else:
|
||||||
|
@ -213,7 +214,8 @@ def getElementPos(obj):
|
||||||
D = np.array(
|
D = np.array(
|
||||||
[L.tangent(0)[0] for L in lines]) #D(irections)
|
[L.tangent(0)[0] for L in lines]) #D(irections)
|
||||||
if np.std( D, axis=0 ).max() < 10**-9: #then linear curve
|
if np.std( D, axis=0 ).max() < 10**-9: #then linear curve
|
||||||
return lines[0].value(0)
|
# return lines[0].value(0)
|
||||||
|
return edge.BoundBox.Center
|
||||||
return pos
|
return pos
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user