BUG? - mirrored bodies

BUG? - mirrored bodies

pludikar
Collaborator Collaborator
839 Views
4 Replies
Message 1 of 5

BUG? - mirrored bodies

pludikar
Collaborator
Collaborator

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 vectorsoriginal body with vectors

This is the same view of the original body, with just the sketch activeraw vectors on original bodyraw 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 vectormirrored body and vector

 

This illustrates the error.

 

raw vector on mirrored bodyraw 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

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
0 Likes
840 Views
4 Replies
Replies (4)
Message 2 of 5

goyals
Autodesk
Autodesk

Thank you for reporting this and another issue. We will look in to this. I will post it on this thread once the fix is available.



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 3 of 5

MichaelT_123
Advisor
Advisor

Hi, Mr. Peter aka Pludicar,

 

... just a thought.

It seems to me that bodies constituencies like edges, faces are processed in their parametric space (not 100% sure as I am just sniffing from a significant distance).

Could you consider modifying a little bit your code to check the values of parameters at coEdges ends by inserting:

(returnValue, parameters) = curveEvaluator2D_var.getParametersAtPoints(points)

and comparing respective values for the straight and mirrored bodies?

 

Regards

MichaelT

 

 

MichaelT
0 Likes
Message 4 of 5

pludikar
Collaborator
Collaborator

Hi @MichaelT_123 ,

 

Thanks for the thought - I tried comparing the start and end parameters of the coEdges with the underlying edges - and... they are consistent with each other.  I'm pretty sure it is just further evidence that the process to create mirrored bodies, and components, is flawed ( That's nice way of saying F***** Up).

 

I've been struggling since before summer of last year to get AD to recognise that there's a significant flaw in their mirrored bodies and components, and hopefully the message has now got through.  I would classify this as a cat 4 or maybe a cat 5 bug ( as in the hurricane categories) - it's not totally devastating, but it causes quite a bit of damage.  If this is inherent in the model structure itself (which I would suggest it is), then it could affect millions of users' existing models, and, I suspect, a cause of existing F360 instability.

 

I added the following after line 42 ( in coEdge for loop) 

 

 

                coEndPoints = coEdge.evaluator.getEndPoints()
                (returnValue, coEdgeParameters) = coEdge.evaluator.getParametersAtPoints(coEndPoints[1:])
                (returnValue, edgeParameters) = coEdge.edge.evaluator.getParametersAtPoints(points[1:])
                print('coEdge parameters = {}; edge Parameters = {}'.format(coEdgeParameters, edgeParameters))

 

This is the result:  You'll notice the start and end parameters are not only, more or less, identical but appear in the same order - the parameters between mirrored body coEdges and edges are just flipped around and negated.  If I'm understanding this correctly, the numbers suggest the coEdges and edges are aligned but, edge vectors are definitely incorrect.  This is consistent with my earlier results.

 

 

coEdge (orginal) Edge(original)
Inner edges  
 (0.0, 11.54197704453183)  (0.0, 11.54197704453183)
 (0.0, 11.54197704453183)  (0.0, 11.54197704453183)
 (0.0, 11.54197704453183)  (0.0, 11.54197704453183)
 (0.0, 11.54197704453183)  (0.0, 11.54197704453183)
Outer Edges  
 (-2.5399999618530296, 0.0)  (-2.5399999618530296, 0.0)
 (-2.539999999999999, 0.0)  (-2.539999999999999, 0.0)
 (-19.041254748394635, 0.0)  (-19.041254748394635, 0.0)
 (-2.539999999999999, 0.0)  (-2.539999999999999, -0.0)
 (-2.539999999999999, 0.0)  (-2.539999999999999, 0.0)
 (-19.041254748394635, 0.0)  (-19.041254748394635, -6.631583118511407e-32)
 (-2.539999999999999, 0.0)  (-2.539999999999999, 0.0)
 (-2.54, 0.0)  (-2.54, -0.0)
 (-19.041254748394635, 0.0)  (-19.041254748394635, 0.0)
 (-2.5400000000000005, 0.0)  (-2.5400000000000005, -4.440892032326177e-16)
 (-2.5399999618530273, 0.0)  (-2.5399999618530273, -0.0)
 (-19.041254748394635, 0.0)  (-19.041254748394635, -0.0)

 

 

Mirrored Body  
coEdge parameters   edge Parameters 
 (-11.54197704453183, 0.0)  (0.0, 11.54197704453183)
 (-11.54197704453183, 0.0)  (0.0, 11.54197704453183)
 (-11.54197704453183, 0.0)  (0.0, 11.54197704453183)
 (-11.54197704453183, 0.0)  (0.0, 11.54197704453183)
 (0.0, 2.5399999618530296)  (-2.5399999618530296, 0.0)
 (0.0, 19.041254748394635)  (-19.041254748394635, -0.0)
 (0.0, 2.5399999618530273)  (-2.5399999618530273, 0.0)
 (0.0, 2.5400000000000005)  (-2.5400000000000005, -4.440892032326177e-16)
 (0.0, 19.041254748394635)  (-19.041254748394635, 0.0)
 (0.0, 2.54)  (-2.54, -0.0)
 (0.0, 2.539999999999999)  (-2.539999999999999, 0.0)
 (0.0, 19.041254748394635)  (-19.041254748394635, -6.631583118511407e-32)
 (0.0, 2.539999999999999)  (-2.539999999999999, 0.0)
 (0.0, 2.539999999999999)  (-2.539999999999999, 0.0)
 (0.0, 19.041254748394635)  (-19.041254748394635, 0.0)
 (0.0, 2.539999999999999)  (-2.539999999999999, 0.0)

 

This is the model I used:

 

Regards

Peter

 

 

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
0 Likes
Message 5 of 5

MichaelT_123
Advisor
Advisor

Hi, Mr. Peter aka Pludicar,

 

Well, it seems the miracle is somewhere else. It is given that it is not for us to discover it but just wait for the sign...

 

With Regards

MichaelT

 

PS. I am too pessimistic. If you have time and passion try once again, but start from the very beginning casting the new net.

MichaelT
0 Likes