简体   繁体   中英

While True loop python

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!

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM