Message 1 of 5
API bug? Mirroring via occurrence.transform results in reversed normals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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? 🙂
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
