- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I realised, that when trying to get a component with the findByentityToken it returns an occurrence object of this component instead of the component itself. This happens only when using occurrence.component.entityToken for generating the entityToken.
This is the code to reproduce:
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
des = adsk.fusion.Design.cast(app.activeProduct)
occ = ui.selectEntity('select Occurrence','Occurrences').entity
comp = occ.component
ui.messageBox(comp.classType())
token = comp.entityToken
entitiesByToken = des.findEntityByToken(token)
ui.messageBox(str([entity.classType() for entity in entitiesByToken]))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
If you use design.allComponents to access the component and generating the token, design.findEntityByToken will return a component as exspected.
I know that I can simply use occ.component on the returned occurrence but I am still wondering about this behavior. Will this always work? Whats the reason for this distinction?
Solved! Go to Solution.