Post #488: ![](https://blenderartists.org/user_avatar/blenderartists.org/draguu/48/15444_2.

📋 Metadata

  • Author: roaoao
  • Date: 2016-12-24 08:57:24
  • Type: answer
  • Quality Score: 7/10
  • Reply to: post_00487

🏷️ Tags

macro python-scripting beginner solved

  • Macro Editor
  • Python Scripting

💬 Content

draguu:

wow that was awesome , man , but i dont understand how it works … i mean

like in this case

ao = active object ,
but i see you have not added if statement anywhere ? only “and” and then draw_menu? what is that … i mean how to do that if this then that thing ???

suppose i want to turn on Xray of an object if wireframe is turned on then ,

if ao.wire == True:
ao.xray = True

how

Sometimes it’s easier to read/use “and/or” instead of “if/else”, especially in single line code. But you can use both:
DO_THIS if THIS else DO_THAT
THIS and DO_THIS or DO_THAT

setattr(ao, "xray", True) if ao.wire == True else None
or 
ao.wire == True and setattr(ao, "xray", True)

❤️ 1 likes


🔗 View on Blender Artists