BrianEkins, that did the trick, thanks!
Here's the updated, working example, for posterity 🙂
import adsk.core, adsk.fusion, adsk.cam, math, traceback
app = adsk.core.Application.get()
root = adsk.fusion.Design.cast(app.activeProduct).rootComponent
design = adsk.fusion.Design.cast(app.activeProduct)
def sphere(radius) -> adsk.fusion.Occurrence:
sketch = root.sketches.add(root.xYConstructionPlane)
center_point = adsk.core.Point3D.create(0, 0, 0)
start_point = adsk.core.Point3D.create(radius/10.0, 0, 0)
arc = sketch.sketchCurves.sketchArcs.addByCenterStartSweep(center_point, start_point, math.pi)
sketch.sketchCurves.sketchLines.addByTwoPoints(arc.startSketchPoint, arc.endSketchPoint)
revolves = root.features.revolveFeatures
revolve_input = revolves.createInput(sketch.profiles.item(0), root.xConstructionAxis,
adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
angle = adsk.core.ValueInput.createByReal(math.pi)
revolve_input.isSolid = True
revolve_input.setAngleExtent(True, angle)
feature = revolves.add(revolve_input) # type: adsk.fusion.Feature
return root.allOccurrencesByComponent(feature.parentComponent)[0]
def run(context):
ui = None
try:
first = sphere(10)
transform = first.transform
transform.translation = adsk.core.Vector3D.create(-5, 0, 0)
first.transform = transform
design.snapshots.add()
print(first.transform.translation.x)
second = sphere(10)
print(first.transform.translation.x)
except:
print(traceback.format_exc())