- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to get all the text on a sketch named “inscricao” on a selection set.
The code is
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
doc = app.activeDocument
selecttext = ui.activeSelections
design = app.activeProduct
components = design.rootComponent.occurrences
i = components.count
# limpa selecção.
selecttext.clear()
# mostra componentes ja existentes
if i > 0 :
for j in range(i) :
components.item(j).isLightBulbOn = True #mostra Componente
componente=components.item(j)
elemento = componente.component
sk = elemento.sketches.itemByName('inscricao')
alltexts=sk.sketchTexts
for text in alltexts:
ui.activeSelections.add(text)
ui.messageBox('selecionado texto')
cmd = ui.commandDefinitions.itemById('CreateSelectionGroupCmd')
cmd.execute()
the error is:
Failed:
Traceback (most recent call last):
File "C:/Users/Pedro/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/SelectText/SelectAllTXT/SelectAllTXT.py", line 27, in run
ui.activeSelections.add(text)
File "C:/Users/Pedro/AppData/Local/Autodesk/webdeploy/production/50d1a2b00ac928c7781cbca6551e586a5384d498/Api/Python/packages\adsk\core.py", line 14924, in add
return _core.Selections_add(self, entity)
RuntimeError: 3 : invalid argument entity
why active selection is not working on this case?
Solved! Go to Solution.