0

I am trying to create a function ex:

RotateElement (doc, lmnt_id, axis, angle)

lmnt_id, axis and angle are inputs that will come in a form of a list. Ex:

axis = [line1, line2, line3]
angle = [20, 25, 30]
lmnt_id = [1, 2, 3]
doc is a constant value

How can i call this function so that it iterates through the inputs. i want it to use line1, 20 and 1 when it runs for the first time but then line2, 25 and 2 when it runs second time and so on. I tried this but it only runs once:

for i in lmnt_ids:
    lmnt_id = i
    for j in axises:
        axis = j
        result.append(ElementTransformUtils.RotateElement (doc, lmnt_id, axis, angle))

Thank you!

1 Answer 1

3

It looks like you want:

for axis_, angle_, lmnt_id_ in zip(axis, angle, lmnt_id):
    result.append(ElementTransformUtils.RotateElement(doc, lmnt_id_, 
                                                      axis_, angle_))

zip will match up the three lists and assign the nth value from each to the loop variables in turn

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.