BUG? - mirrored bodies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @goyals,
I've reported mirror related bugs before - latest one here, which has been accepted as a bug. However, I've found yet another inconsistency, this time in the relationship between co-edges and the underlying edges in bodies that have been created via mirroring.
The script below is meant to identify any inside corner, and will create an illustrative sketch lines where the inside corners are. The original body works as expected, the mirrored body does not.
import adsk.core, adsk.fusion, traceback
import sys
#import logging
import time
#logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
def timer(func):
def inside(*args, **kwargs):
startTime = time.time()
result = func(*args, **kwargs)
print('time taken = {}'.format(time.time() - startTime))
return result
return inside
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
root = design.rootComponent
@timer
def findInnerCorners(face):
sketch.isComputeDeferred = True
face1 = adsk.fusion.BRepFace.cast(face)
if face1.objectType != adsk.fusion.BRepFace.classType():
return
if face1.geometry.surfaceType != adsk.core.SurfaceTypes.PlaneSurfaceType:
return
faceNormal = face1.evaluator.getNormalAtPoint(face1.pointOnFace)[1]
for loop in face1.loops:
lastCoEdge = loop.coEdges.item(loop.coEdges.count -1)
points = lastCoEdge.edge.evaluator.getEndPoints()
print('last edge startpoint; ({},{},{}); endPoint; ({},{},{})'.format(round(points[1].x,2), round(points[1].y,2), round(points[1].z,2), round(points[2].x,2), round(points[2].y,2), round(points[2].z,2)))
vLast = points[1].vectorTo(points[2]) if lastCoEdge.isOpposedToEdge else points[2].vectorTo(points[1])
vLast.normalize()
vLast = vLast.copy()
for coEdge in loop.coEdges:
points = coEdge.edge.evaluator.getEndPoints()
print('isOpposedTo = {}'.format(coEdge.isOpposedToEdge))
print('co-edge startpoint; ({},{},{}); endPoint; ({},{},{})'.format(round(points[1].x,2), round(points[1].y,2), round(points[1].z,2), round(points[2].x,2), round(points[2].y,2), round(points[2].z,2)))
v1 = points[1].vectorTo(points[2]) if coEdge.isOpposedToEdge else points[2].vectorTo(points[1])
v1.normalize()
print('Last vector; ({},{},{}); Next Vector; ({},{},{})'.format(round(vLast.asPoint().x,2), round(vLast.asPoint().y,2), round(vLast.asPoint().z,2), round(v1.asPoint().x,2), round(v1.asPoint().y,2), round(v1.asPoint().z,2)))
cross = adsk.core.Vector3D.cast(None)
cross = vLast.crossProduct(v1)
print('cross vector; ({},{},{})'.format(round(cross.asPoint().x,2), round(cross.asPoint().y,2), round(cross.asPoint().z,2),))
endPoint = adsk.core.Point3D.cast(None)
endPoint = points[1].copy()
endPoint.translateBy(cross)
sketch.sketchCurves.sketchLines.addByTwoPoints(sketch.modelToSketchSpace(points[1]), sketch.modelToSketchSpace(points[2]))
if cross.angleTo(faceNormal)!=0:
sketch.sketchCurves.sketchLines.addByTwoPoints(sketch.modelToSketchSpace(points[1]), sketch.modelToSketchSpace(endPoint)) #if not coEdge.isOpposedToEdge else sketch.sketchCurves.sketchLines.addByTwoPoints(points[2], endPoint)
vLast = v1.copy()
sketch.isComputeDeferred = False
faceSelection = adsk.core.Selection.cast(ui.selectEntity('select a face', 'Faces'))
sketch = root.sketches.add(faceSelection.entity)
findInnerCorners(faceSelection.entity)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
This shows the result of the script on an original body - note the the vector representations at the corner are correct.original body with vectors
This is the same view of the original body, with just the sketch activeraw vectors on original body
This is the view of the same body, but after mirroring - note that the vectors are not only in the wrong place, but are not associated with the inside corner. This is indicative of the underlying edge not being consistent with
coEdge.isOpposedToEdge - either the loop direction is not consistent or the co-edge and edge relationship is wrong.
mirrored body and vector
This illustrates the error.
raw vector on mirrored body
It is clear, from all the issues I've had that mirroring is significantly flawed.
I can create a screencast, if absolutely necessary, but I'm hoping this is obvious and easy to reproduce
Regards
Peter
Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
