简体   繁体   English

而True循环python

[英]While True loop python

I'm a beginner and I would like to make a while loop in python. 我是一个初学者,我想在python中做一个while循环。 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). 首先,您将int关键字(整数类型)用作变量,并将'int'变量显式设置为False(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. ...而且我不太了解这是什么move

If rs.MoveObject() modifies the object, you just need rs.MoveObject(curve1, vec) ; 如果rs.MoveObject()修改了对象, rs.MoveObject(curve1, vec)需要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). 如果返回修改后的对象,则需要使用curve1 = rs.MoveObject(curve1, vec) (并且当前代码将导致无限循环)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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