How to get an ID of a variable.

Posted on
Mon Sep 23, 2013 8:40 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

How to get an ID of a variable.

In a Python script, Is there an easy way to get the ID of an Indigo variable (if you know its name) without having to iterate through the list of variables doing a name comparison :?:

Can't seem to find the answer to this one :)

Posted on
Mon Sep 23, 2013 9:00 am
RogueProeliator offline
User avatar
Posts: 2506
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: How to get an ID of a variable.

You should be able to refer to it by name, then the ID is just a property:

Code: Select all
indigo.variables["MyVarName"].id

Adam

Posted on
Mon Sep 23, 2013 9:05 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: How to get an ID of a variable.

RogueProeliator wrote:
You should be able to refer to it by name, then the ID is just a property:

Code: Select all
indigo.variables["MyVarName"].id

Adam

Thanks for the quick feedback :D

Posted on
Mon Sep 23, 2013 9:18 am
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: How to get an ID of a variable.

It is recommended if possible to use the ID in the script since it won't change if the object is renamed. There are cases where you may not want to do this though, in which case here is a slightly more efficient version of what Adam posted:

Code: Select all
indigo.variables.getId("MyVarName")

Image

Posted on
Mon Sep 23, 2013 10:47 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: How to get an ID of a variable.

matt (support) wrote:
It is recommended if possible to use the ID in the script since it won't change if the object is renamed. There are cases where you may not want to do this though, in which case here is a slightly more efficient version of what Adam posted:

Code: Select all
indigo.variables.getId("MyVarName")

Sounds like I am spoilt for choice - thanks for the feedback :D

Posted on
Mon Sep 23, 2013 12:40 pm
RogueProeliator offline
User avatar
Posts: 2506
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: How to get an ID of a variable.

Sounds like I am spoilt for choice - thanks for the feedback

Yeah, you get used to this... you know a good, reliable way to do something then all of a sudden Matt or Jay crack their respective coding whips and tell you how you SHOULD be doing it. :) You learn something new virtually every day reading the forums...

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests