Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Several posts on this in the past. Pretty simple. Create a SelectionSet via the API (I use large assemblies - and want selection sets for the different components in my designs - mainly so I can simplify creation of drawings).
Advice ? or BUG ?
Failing:
Failed:
Traceback (most recent call last):
File "D:/Users/Public/G2VDesign_OneDrive/OneDrive - G2V DESIGN PTY LTD/Fusion 360 Tools/Add-ins/$GV Test Bed/$GV Test Bed.py", line 36, in run
design.selectionSets.add(compsToAdd,'NewSelectionSet')
File "C:\Users/gvisc/AppData/Local/Autodesk/webdeploy/production/99249ee497b13684a43f5bacd5f1f09974049c6b/Api/Python/packages\adsk\core.py", line 17723, in add
return _core.SelectionSets_add(self, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 2 : InternalValidationError : owningCompOfEntity == owningCompOfGroups
Code:
import adsk.core, adsk.fusion, adsk.cam, traceback
app = None
ui = None
design:adsk.fusion.Design = None
def isDesignLoaded():
root = design.rootComponent
occs = root.allOccurrences
if len(occs) == 0:
return False
else:
return True
def run(context):
global app, ui, design
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
allComponents = design.allComponents
if not isDesignLoaded():
ui.messageBox('There are no components in this design.')
return
compsToAdd = []
compsToAdd.append(allComponents[0])
msg = f'{compsToAdd[0].name}'
app.log(msg)
design.selectionSets.add(compsToAdd,'NewSelectionSet')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.