李·麦克
有很多方法可以解决这个问题,但在找到解决方案之前,您需要
澄清流程。在您的示例中,您使用的是整数90和180。对我来说这意味着
它们是用户输入的值,因为从实体(如直线)获得的任何角度
将是一个实数&可能以弧度而不是度为单位。
那是哪一个?
请注意,对于接近所需值的值,通常也必须使用模糊因子。
由于存在舍入误差,ACAD尤其如此。
这是您的示例已更正&没有给出正确的结果,您使用了错误的斜杠字符
- (if (or (/= elbang 90) (/= elbang 180))
- (progn
- "run elbow draw program"
- )
- ) ; end if
在您给出的简单示例中,我会这样做,假设只测试整数。
- ;; elbang is /= 90 AND /= 180
- (if (and (/= elbang 90) (/= elbang 180))
- (progn
- (princ "run elbow draw program")
- )
- ) ; end if
- ;; OR returns true if either is true
- ;; OR returns nil if Both are false
- ;; so if Both are false, NOT returns True
- (if (not (or (= elbang 90) (= elbang 180)))
- (progn
- (princ "run elbow draw program")
- )
- ) ; end if
- ;; Another way to test
- ;; if var is not a member of the list
- (if (not (member elbang '(90 180)))
- (progn
- (princ "run elbow draw program")
- )
- ) ; end if
- ;; Another way to test
- ;; if var is not a member of the list
- (if (not (vl-position elbang '(90 180)))
- (progn
- (princ "run elbow draw program")
- )
- ) ; end if
- ;; This one is a little tricky
- ;; returns True if both test are true, like this
- ;; (setq elbang 20)
- ;; (/= 90 elbang) -> true
- ;; (/= elbang 180) -> true
- ;; both true then the prg will execute
- ;; (setq elbang 90)
- ;; (/= 90 elbang) -> flase
- ;; (/= elbang 180) -> true
- ;; any false will return false then the prg will NOT execute
- ;; This is like an AND,
- (if (/= 90 elbang 180) ; elbang must be in the middle
- (progn
- (princ "run elbow draw program")
- )
- ) ; end if
|