- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to modify a script from https://youtu.be/QYsf8y4nZ4E which currently adds geometry to an existing sketch.
I'd like it to work if there is no active sketch, similar to the create sketch command,, by getting a face or plane from the user and creating a new sketch.
Here's what I have so far.
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
component = design.activeComponent
if app.activeEditObject.objectType != adsk.fusion.Sketch.classType():
sketchPlane = ui.selectEntity('Select a plane or planar face', 'PlanarFaces,ConstructionPlanes')
sketch = component.sketches.add(sketchPlane)
else:
sketch = adsk.fusion.Sketch.cast(app.activeEditObject)
when I run this I get
Failed:
Traceback (most recent call last):
File "/Users/rick/Library/Application Support/Autodesk/Autodesk Fusion 360/API/Scripts/adsk2020ai/adsk2020ai.py", line 15, in run
sketch = component.sketches.add(sketchPlane)
File "/Users/rick/Library/Application Support/Autodesk/webdeploy/production/6a4ee1e135d539f7735a031beb7a5c1c01c7a76f/Autodesk Fusion 360.app/Contents/Api/Python/packages/adsk/fusion.py", line 38203, in add
return _fusion.Sketches_add(self, *args)
RuntimeError: 3 : not a planar entity
I guess I need to cast the result of the ui.selectEntity to some type, but I can't seem to figure out what is needed to satisfy the requirement for a 'planar entity'.
Solved! Go to Solution.