Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API bug? Mirroring via occurrence.transform results in reversed normals

4 REPLIES 4
Reply
Message 1 of 5
JesusFreke
271 Views, 4 Replies

API bug? Mirroring via occurrence.transform results in reversed normals

I was playing around with doing a mirror operation by tweaking an occurrence's transformation matrix. If you mirror by

1 axis or 3 axes, you end up with a body that looks like it has reversed normals. Although, if you modify the object (e.g. do a combine operation on it), the normals seem to get fixed.

 

Mirroring by 2 axes does not exhibit the bug -- likely 2 normal inversions cancelling each other out? 🙂

 

mirror_normal_bug.png

 

code:

 

import adsk.core
import adsk.fusion

app = adsk.core.Application.get()
root = app.activeProduct.rootComponent


def box(x, y, z, *, name="Box"):
    brep = adsk.fusion.TemporaryBRepManager.get()
    box_body = brep.createBox(adsk.core.OrientedBoundingBox3D.create(
        adsk.core.Point3D.create(x/2, y/2, z/2),
        adsk.core.Vector3D.create(1, 0, 0),
        adsk.core.Vector3D.create(0, 1, 0),
        x, y, z))
    occurrence = root.occurrences.addNewComponent(adsk.core.Matrix3D.create())
    occurrence.component.name = name
    base_feature = occurrence.component.features.baseFeatures.add()
    base_feature.startEdit()
    occurrence.component.bRepBodies.add(box_body, base_feature)
    base_feature.finishEdit()
    return occurrence


def run(context):
    original = box(1, 1, 1, name="original")
    mirrored = box(1, 1, 1, name="mirror")

    transform = mirrored.transform
    transform.setCell(0, 0, -1)
    transform.setCell(1, 1, 1)
    transform.setCell(2, 2, 1)
    mirrored.transform = transform
4 REPLIES 4
Message 2 of 5
JesusFreke
in reply to: JesusFreke

And yes, I know the usual way to mirror is via a mirror feature 🙂

Message 3 of 5
BrianEkins
in reply to: JesusFreke

It is a bug in the API, but the bug is that it's allowing you to set the transform with a matrix that defines a mirror.  Fusion doesn't expect this internally and the API shouldn't let you do it.  There's supposed to be a check in the API when setting the transform to verify that the matrix is only defining translation and rotation.  Any scaling, mirroring, or other non-standard transforms should fail.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 4 of 5
JesusFreke
in reply to: BrianEkins

Fair enough :). As far as I can tell, there is a check to disallow non-uniform scaling at least. But uniform scaling does seem to work.

Message 5 of 5
goyals
in reply to: JesusFreke

UP-40767 is created to track this. Thank you for reporting it.



Shyam Goyal
Sr. Software Dev. Manager

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report