How do i create circular pattern in sketch using API?

How do i create circular pattern in sketch using API?

Anonymous
Not applicable
2,180 Views
3 Replies
Message 1 of 4

How do i create circular pattern in sketch using API?

Anonymous
Not applicable

I'm wokring on a little helical gear gernerator.

 

I have a sketch with gear tooth outline made from a few arcs and splines.

I'm trying to make a circular pattern in the sketch to copy the teeth shape around the gear.

I can't seem to find the right API to do a Circular Pattern as I can do in the sketch editor.

 

 

I tried to use the only API that seemed to work with Circular patterns (circularPatternFeatures), but it does not work for me:

 

 

                        var stuff_to_pattern = adsk.core.ObjectCollection.create();
                        
                        stuff_to_pattern.add(left_bottom_arc);
                        stuff_to_pattern.add(left_involute);
                        stuff_to_pattern.add(top_arc);
                        stuff_to_pattern.add(right_involute);
                        stuff_to_pattern.add(right_bottom_arc);
                        
                        var pattern_input = root.features.circularPatternFeatures.createInput(stuff_to_pattern, root.zConstructionAxis);
                        pattern_input.quantity = adsk.core.ValueInput.createByReal(teeth);
                        root.features.circularPatternFeatures.add(pattern_input);

 

When I run this I get an error saying "inputEntities should be of a single type."

 

I am confused. Am I using the wrong thing?

 

0 Likes
2,181 Views
3 Replies
Replies (3)
Message 2 of 4

ekinsb
Alumni
Alumni

There are two different pattern commands in Fusion.  One when working with sketches and one when working with the model.  The commands are completely different and support different capabilities.  The API currently only supports patterning in the model and not a sketch.

 

In many cases, it's better to do the patterning in the model anyway.  For example, in your case, you can create the sketch for a single gear tooth and then use it to create a single gear tooth in the model and then pattern it to create the full gear.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 4

marcinszydlowski.1984
Enthusiast
Enthusiast

Hello all,

 

I know this is probably outdated but I had similar problem: I had a sketch but i wanted pattern without extruding shapes. It can be easily done by copying sketch elements using rotations. If someone has still problem with such cases, here are simple solution for rotating on XY plane:

 

    entities = adsk.core.ObjectCollection.create()
    entities.add(filletLeft)
    entities.add(rootLineLeft)
    entities.add(splineLeft)
    entities.add(toothTipCurve)
    entities.add(splineRight)
    entities.add(rootLineRight)
    entities.add(filletRight)
        
    normal = sketch.xDirection.crossProduct(sketch.yDirection)
    normal.transformBy(sketch.transform)
    origin = sketch.origin
    origin.transformBy(sketch.transform)
    rotationMatrix = adsk.core.Matrix3D.create()
    step = 2 * math.pi / teethNumber

    for i in range(1, int(teethNumber)):
        rotationMatrix.setToRotation(step * i, normal, origin)
        sketch.copy(entities, rotationMatrix)
Message 4 of 4

adminTCYL2
Enthusiast
Enthusiast

Thank you for this nice pice of code! It helped me a lot!

 

0 Likes