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: 

Use API to Mirror Sketch

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Brian_Sullivan
964 Views, 5 Replies

Use API to Mirror Sketch

There are many examples to Sketch Features.

 

I can't find one for Mirroring lines.

 

Any help appreciated. Thanks

Tags (1)
5 REPLIES 5
Message 2 of 6
BrianEkins
in reply to: Brian_Sullivan

The equivalent of the Mirror command is not available in the API.  However, it is possible to still end up with the same results.  You can create the geometry that is the mirror image and then add the symmetry constraint between it and the original geometry so that it continues to behave correctly.  The GeometricConstraints collection supports the AddSymmetry method.  You'll mostly apply this to the points because the geometry is dependent on them.  The exception to this is arcs and circles to be able to control the radius.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 6
Brian_Sullivan
in reply to: BrianEkins

Thanks. 


Took a few hours to get from that to something that actually worked

  • First got it to work in GUI
  • Don't forget to make points that are on the mirror line symetric!

Then some code

        app = adsk.core.Application.get()
        ui  = app.userInterface
        product = app.activeProduct
        rootComp = product.rootComponent
        sketch = rootComp.sketches.add(rootComp.xYConstructionPlane,)
        
        #draw line
        p1    = adsk.core.Point3D.create(1,1,0)     
        p2    = adsk.core.Point3D.create(2,2,0)     
        line1 = sketch.sketchCurves.sketchLines.addByTwoPoints(p1, p2)
        
        #create a mirror (constructin) line 
        x1    = adsk.core.Point3D.create(0,0,0)     
        x2    = adsk.core.Point3D.create(0,2,0)     
        lineX = sketch.sketchCurves.sketchLines.addByTwoPoints(x1, x2)
        lineX.isConstruction = True 
        
        #mirrorline(s) - Draw on top of lines, mirror will move them 
        m1      = adsk.core.Point3D.create(1,1,0) 
        m2      = adsk.core.Point3D.create(2,2,0) 
        mirror1 = sketch.sketchCurves.sketchLines.addByTwoPoints(m1, m2)
            
        #Add Symatry (Don't forget to add points on the mirror line )
        sketch.geometricConstraints.addSymmetry(line1.startSketchPoint, mirror1.startSketchPoint, lineX)
        sketch.geometricConstraints.addSymmetry(line1.endSketchPoint,   mirror1.endSketchPoint, lineX)
Message 4 of 6
MichaelT_123
in reply to: BrianEkins

Hi Mr. Ekins

 

Mirroring in geometry and even topology has been known for a long time. Even Aphrodite has been using it quite often.

From a mathematical standpoint is done by reversing axis sign (not a secret at all), so simple addition of this functionality (on sketch or model level will do the trick ... no matter what). It is sad to see that people desperate for such operation, resort to spending hours.... writing their own scripts!

As I pointed out in my previous post, they deserve a Nobel prize for the excessive determination.

To switch to a better mood... Just imagine the committee Smiley LOL.

 

With Regards

MichaelT

 

Mr. Ekins, although this is a replay to your post, it is actually addressed to the whole TF360.

 

MichaelT
Message 5 of 6

True it is simple to just draw the other side, reversing the axis. 

 

I needed actual mirroring. Where the if I latter grabbed a point and moved it, the other side would move as well.

 

Thanks

Message 6 of 6
ben
Observer
in reply to: BrianEkins

Just another pathetic example of self-absorbed developers who ignore the "if it's not broke don't fix it" axiom.

 

They have taken a simple and useful feature and replaced it with something obtuse and complicated....

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