📋 Metadata

💬 Content

aMars:

Is it possible to run a for loop in the command area or is it necessary to use an external script?

As Way2Close said, you can use List Comprehensions.
For example this code:

for a in range(5):
    if a < 2:
        b = a * 2
        print(b)

same as:

[(locals().update(b=a * 2), print(locals()["b"])) for a in range(5) if a < 2]

Note that we have to mark local variables (c) as global if we want to use it in list comprehensions:

c = 2
for a in range(5):
    if a < 2:
        b = a * c
        print(b)




global c; c = 2; [(locals().update(b=a * c), print(locals()["b"])) for a in range(5) if a < 2]

🔗 View on Blender Artists