PDA

View Full Version : Ask Layout if an Item is set to Unseen by Camera or Matte Object?



NanoGator
05-04-2015, 09:56 PM
Hi All,

I was just wondering how I would go about asking Layout if an Item has 'Unseen by Camera" on. My early digging into it has been unfruitful.

B

ernpchan
05-04-2015, 10:54 PM
It's under flags in the lwsdk.LWObjectInfo section.

flags(LWItemID item) → unsigned int
Returns the state of certain object settings as bits combined using bitwise-or.

Ryan Roye
05-05-2015, 05:57 PM
A valid syntax is:

items = lwsdk.LWInterfaceInfo().selected_items()[0]
findvar = lwsdk.LWObjectInfo().flags(items) & lwsdk.LWOBJF_UNSEEN_BY_CAMERA

findvar will return 0 if the option is unchecked, and a number higher than 0 if it is checked. You can then do basic python logic to take it from there.

NanoGator
05-06-2015, 01:46 PM
A valid syntax is:

items = lwsdk.LWInterfaceInfo().selected_items()[0]
findvar = lwsdk.LWObjectInfo().flags(items) & lwsdk.LWOBJF_UNSEEN_BY_CAMERA

findvar will return 0 if the option is unchecked, and a number higher than 0 if it is checked. You can then do basic python logic to take it from there.

That is very helpful, thank you, I had no idea that LWObjectInfo existed!

I did want to ask one more question:




findvar = lwsdk.LWObjectInfo().flags(items) & lwsdk.LWOBJF_UNSEEN_BY_CAMERA



I thought I understood Python pretty well, but could you ask me what this line does? Is it looking for the Unseen_By_Camera constant inside a list of flags?

ernpchan
05-06-2015, 01:57 PM
This part is getting all the flag states of the item (items).

lwsdk.LWObjectInfo().flags(items)

This part is doing the bitwise operation for the specific flag (lwsdk.LWOBJ_UNSEEN_BY_CAMERA)

lwsdk.LWObjectInfo().flags(items) & lwsdk.LWOBJF_UNSEEN_BY_CAMERA

findvar is just the variable assignment. It'll be one of two values based on the state in Layout. From there you can do what you want based on the value of findvar (true/false). I don't think the value is actual True/False but a numerical value but it'll only ever be of two values since the state in Layout is checked/unchecked.

NanoGator
05-06-2015, 01:59 PM
Thank you!