Damien Keraudren Posted September 30, 2021 Report Share Posted September 30, 2021 Hi, I want to show an action only if the asset have a specific component, I tried a for loop in the discover method returning True if a component name match the component i'm looking for, but it doesn't seems to work. Is this something possible and I'm doing it the wrong way or not possible at all ? Link to comment Share on other sites More sharing options...
Lorenzo Angeli Posted September 30, 2021 Report Share Posted September 30, 2021 Hi @Damien Keraudren you approach seems quite right to me. Would you mind sharing the discover method code so we can have a closer look ? Cheers. L. Link to comment Share on other sites More sharing options...
Damien Keraudren Posted September 30, 2021 Author Report Share Posted September 30, 2021 it was something like this @Lorenzo Angeli def discover(self, session, entities, event): '''Return True if only one asset version is selected, else the action don't show up''' if len(entities) != 1: return False entity_type, entity_id = entities[0] if entity_type == 'AssetVersion': query = 'AssetVersion where id = {}'.format(entity_id) av = session.query(query).first() components = av['components'] for component in components: if component['name'] == 'main': return True return False Link to comment Share on other sites More sharing options...
Damien Keraudren Posted September 30, 2021 Author Report Share Posted September 30, 2021 So after some tryings, I got it to work, the problem wasn't in the discover method, i just forgot the of class when i copy paste from my base action Link to comment Share on other sites More sharing options...
Lorenzo Angeli Posted September 30, 2021 Report Share Posted September 30, 2021 Great to hear @Damien Keraudren! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now