In another post you replied about using a pre-existing circle sketch which is exactly what I am trying to do.
I copied your script from my post and added your pre existing circle code and I get an error that the pre-existing circle is an "invalid argument entity"
The sketch is created with the circle.
#Fusion360API Python script
import adsk.core, adsk.fusion, traceback
import math
_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)
def run(context😞
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
product = _app.activeProduct
design = adsk.fusion.Design.cast(product)
occs = design.rootComponent.occurrences
mat = adsk.core.Matrix3D.create()
newOcc = occs.addNewComponent(mat)
newComp = adsk.fusion.Component.cast(newOcc.component)
sketches = newComp.sketches
xyPlane = newComp.xYConstructionPlane
center = adsk.core.Point3D.create(0, 0, 0)
# Create the body
bodySketch = sketches.add(xyPlane)
bodyCircle = bodySketch.sketchCurves.sketchCircles.addByCenterRadius(center, 1 * 2.54)
# Coil parameters
CoilDiameter = 10
CoilPitch = 4
CoilHeight = 30
SectionSize = 1
CoilFeatureType = 2
CoilFeatureSectionType = 1
# wait CommandIDs
#waitLst = ('PrimitiveCoil','CircleCenterRadius')
# call Coil command
#_app.executeTextCommand(u'Commands.Start PrimitiveCoil')
_ui.activeSelections.add(bodyCircle) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
_app.executeTextCommand(u'Commands.Start Coil')
# wait
while True:
actCmd = _ui.activeCommand
adsk.doEvents()
if actCmd in waitLst:
continue
break
# Cancel check
if _ui.activeCommand != 'Coil':
return
# setting parameters
cmds = [
u'Commands.SetDouble SectionSize {}'.format(SectionSize),
u'Commands.SetDouble CoilPitch {}'.format(CoilPitch),
u'Commands.SetDouble CoilHeight {}'.format(CoilHeight),
u'Commands.SetDouble CoilFeatureType {}'.format(CoilFeatureType)
u'Commands.SetDouble CoilFeatureSectionType {}'.format(CoilFeatureSectionType)
]
#[_app.executeTextCommand(cmd) for cmd in cmds]
# command commit
_app.executeTextCommand(u'NuCommands.CommitCmd')
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))