Creating a Coil similar to coil feature?

Creating a Coil similar to coil feature?

skln131313
Community Visitor Community Visitor
472 Views
2 Replies
Message 1 of 3

Creating a Coil similar to coil feature?

skln131313
Community Visitor
Community Visitor

I am trying to create a coil programically, but it seems for whatever reason the CoilFeature does not have an API exposed to create an actual CoilFeature. A workaround is to use something called TextCommand to which there is no official documentation and the official documentation links to a user testing it to try to figure out how it works. Truly amazing they want $700/year for that. I got it working creating the coil, but after 10 seconds of the command finishing it always crashes.

 

So is there another way to create a coil similar to the one the feature creates? I'd need a square profile for the coil. I was using the height and pitch option for the coil along with the coil being on the outside of the diameter. I'm not sure how to do this especially to have it be parametric so that I'm not creating straight line segments to define the path of the coil.

 

0 Likes
473 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

Hi @skln131313 -San.

 

I tried using the text command, but I could not make it work either.

Instead, I made a sample using TemporaryBRepManager and PipeFeature.

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion
import math

def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface
        des: fusion.Design = app.activeProduct
        root: fusion.Component = des.rootComponent

        create_coil_like(
            root.xYConstructionPlane,
            core.Point3D.create(2,1,0),
            1,
            10,
            5,
            0.1,
            0,
        )

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def create_coil_like(
        supportPlane: fusion.ConstructionPlane,
        centerPoint: core.Point3D,
        diameter: float,
        revolutions: float,
        height: float,
        sectionSize: float,
        angle: float = 0,
) -> fusion.PipeFeature:

    # wire
    startPoint: core.Point3D = centerPoint.copy()
    startPoint.translateBy(
        core.Vector3D.create(diameter * 0.5, 0, 0)
    )

    tmpMgr: fusion.TemporaryBRepManager = fusion.TemporaryBRepManager.get()
    helixWire: fusion.BRepBody = tmpMgr.createHelixWire(
        centerPoint,
        supportPlane.geometry.normal,
        startPoint,
        height / revolutions,
        revolutions,
        math.radians(angle),
    )

    crv: core.NurbsCurve3D = helixWire.wires[0].edges[0].geometry

    # sketch
    comp: fusion.Component = supportPlane.component
    skt: fusion.Sketch = comp.sketches.add(
        supportPlane
    )
    skt.name = "coil like support"
    fixedSplines: fusion.SketchFixedSplines = skt.sketchCurves.sketchFixedSplines
    sktCrv: fusion.SketchFixedSpline = fixedSplines.addByNurbsCurve(crv)

    # pipe
    pipes: fusion.PipeFeatures = comp.features.pipeFeatures
    pipeIpt: fusion.PipeFeatureInput = pipes.createInput(
        fusion.Path.create(sktCrv, fusion.ChainedCurveOptions.noChainedCurves),
        fusion.FeatureOperations.NewBodyFeatureOperation,
    )
    pipeIpt.sectionSize = core.ValueInput.createByReal(sectionSize)

    return pipes.add(pipeIpt)

1.png

0 Likes
Message 3 of 3

dbunch211
Contributor
Contributor

I draw a helix path to create threads in my add-in which is essentially a coil path.  You could take a look at that code & change the profile accordingly to what you want.  I draw one revolution of the helix & then use the path pattern to generate the rest of the threads which has been the fastest method for me in generating these threads.  Actually, I could probably add another tab to this with an option for coils with different profiles fairly easily.