0

I'm a beginner and I would like to make a while loop in python. I have two intersecting coplanar curves and I would like to move the first curve a certain vector on the common plane until they no longer intersect. I tried something like:

vec = [0,0.1,0]
int = True
while True:
    move=rs.MoveObject(curve1,vec)
    int=rs.CurveCurveIntersection(curve1, curve2)
    if int = False:
        break

Anyone knows what am I doing wrong? Thanks in advance!

5
  • 2
    Don't use int as a variable name, you are masking the built-in type here. Commented Mar 4, 2014 at 17:51
  • 2
    What error are you getting? Commented Mar 4, 2014 at 17:51
  • For starters, you need == instead of =: if int == False: (or just if not int:). Beyond that and the int @MartijnPieters mentioned, you'll need to tell us specifically what's happening (errors? show us the traceback) and how that's different from the output you expect to see Commented Mar 4, 2014 at 17:51
  • You could simplify it to if not rs.CurveCurveIntersection(curve1, curve2): break and lose the int variable altogether. Commented Mar 4, 2014 at 17:52
  • Sure, sorry for not posting the error! Commented Mar 4, 2014 at 18:10

2 Answers 2

3

First of all, you are using the int key word (integer type) as a variable and explicitly setting the 'int' variable to False (which is a syntax error in an if). This can mess up your system. You are also not showing what the error message is.

intersect = rs.CurveCurveIntersection(curve1, curve2)
if not intersect:
  break
Sign up to request clarification or add additional context in comments.

Comments

1

Could be simplified to

vec = [0, .1, 0]

while rs.CurveCurveIntersection(curve1, curve2):
    move = rs.MoveObject(curve1, vec)

... and I don't quite understand what move is.

If rs.MoveObject() modifies the object, you just need rs.MoveObject(curve1, vec);

if it returns a modified object, you need curve1 = rs.MoveObject(curve1, vec) instead (and your current code would result in an endless loop).

3 Comments

The initial value of curve1 and curve2 may not intersect. You would need to do the first move before entering the while loop as you show it.
@sabbahillel: I believe that is a mistake in his code - he assumes the curves are already intersecting and thus must be moved. If the two curves do not initially intersect, there is no reason to run the body of the while loop at all.
OK I had assumed that the test was that the curve is moved whether or not it intersects and then the checks would be done. Since we do not know what he wants, either could be true.

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.