songyuan 发表于 2003-5-27 20:36:00

紧急!!!请问有谁能帮帮我解决这样一个问题,多谢!

我设计的一个程序中,出现这样的一个情况,就是前面我定义了5五个YES和NO的选择,既是让操作者选择Y和N,但是我的这个程序在现实中是不允许全部都选择N的,所以,我想请教各位高手,能不能教我用AUTOLISP定义一个这样的函数,每出现一次N,这个变量就自加1,当这个变量等于一个数,比如说自加到6时,就提示错误,并重新做开始说到的那5个Y或N的选择。用C语言我会编写,但是我才开始用AUTOLISP没有多久,很是菜,所以请各位高手赐教,不胜感谢。

gmliux 发表于 2003-5-27 22:50:00

while函数

试一试,应该可以。

songyuan 发表于 2003-5-28 08:36:00

求助!!多谢大虾的指导

但是你能不能帮我编写一个比如说有两个N的这种情况???我对autolisp编写不是很熟悉。先谢了

meflying 发表于 2003-5-28 08:49:00

简单

(while (>= m 2)
(setq m 0)
(setq a (getstring "Sure<Y>:"))
(if (or (= a nil) (= a "Y") (= a "y"))
   (setq a "Y")
   (setq m (1+ m))
)
    (setq a (getstring "Sure<Y>:"))
(if (or (= a nil) (= a "Y") (= a "y"))
   (setq a "Y")
   (setq m (1+ m))
)
)

songyuan 发表于 2003-5-28 10:20:00

那么镶套在这段语句中怎么实现呢???

;插入断路器隔离开关串1
(defun inchuanABC ()
(command "layer" "s" "breaker" "")
(prompt "\n注意!!!在选择断路器串类型时不能全部为“N”!!! ")
(initget 3 "Y y n N")
(setq answerA (getkword "\n需要完整串吗?(Y/N): "))
(if (= answerA "Y")
   (progn
    (setq nct (getint "\n请输入完整串个数:"))
    (prompt "请在母线W1的上找完整串的插入基点: ")
    (repeat nct
   (setq p22 (getpoint "\n 请找第N个块的插入基点:"))
   (command "insert" "c:\\song\\c6.dwg" p22 bl bl "" "")
    )
   )
)
;插入断路器隔离开关串2
(initget 3 "Y y n N")
(setq answerB (getkword "\n需要上部串吗?(Y/N): "))
(if (= answerB "Y")
   (progn
    (setq nct (getint "\n请输入上部串个数:"))
    (prompt "请在母线W1的上找上部串的插入基点: ")
    (repeat nct
   (setq p22 (getpoint "\n 请找第N个块的插入基点:"))
   (command "insert" "c:\\song\\c9.dwg" p22 bl bl "" "")
    )
   )
)
;插入断路器隔离开关串
(initget 3 "Y y n N")
(setq answerC (getkword "\n需要下部串吗?(Y/N): "))
(if (= answerC "Y")
   (progn
    (setq nct (getint "\n请输入下部串个数:"))
    (prompt "\n请在母线W1的上找下部串的插入基点: ")
    (repeat nct
   (setq p22 (getpoint "\n 请找第N个块的插入基点:"))
   (command "insert" "c:\\song\\c10.dwg" p22 bl bl "" "")
    )
   )
)
)

songyuan 发表于 2003-5-28 10:48:00

求助meflying兄及其它英雄帮忙!!

我在上个求助中的意思是当我都选择N时,程序就会提示错误并返回重新开始做选择,在我给出的那段程序中怎么实现???先在这里多谢各位英雄和特别感谢meflying兄了

gmliux 发表于 2003-5-28 23:45:00

逻辑判断

在循环中加cond函数,当有五个N选择,开始新一轮,也许不错。

龙龙仔 发表于 2003-5-29 08:05:00

試試

;;;插入断路器隔离开关串1
(defun INCHUANABC (/ ANSWERA ANSWERB ANSWERC)
(command "layer" "s" "breaker" "")
(while (or (and (= ANSWERA NIL) (= ANSWERB NIL) (= ANSWERC NIL))
             (and (= ANSWERA "Y") (= ANSWERB "Y") (= ANSWERB "Y"))
       )
    ;;(prompt "\n注意!!!在选择断路器串类型时不能全部为\"N\"!!!")
    (initget 3 "Y N")
    (setq ANSWERA (getkword "\n需要完整串吗?(Y/N): "))
    (if        (= ANSWERA "Y")
      (progn
        (setq NCT (getint "\n请输入完整串个数: "))
        (prompt "请在母线W1的上找完整串的插入基点: ")
        (repeat        NCT
          (setq P22 (getpoint "\n 请找第N个块的插入基点: "))
          (command "insert" "c:\\song\\c6.dwg" P22 BL BL "" "")
        )
      )
    )
    ;;插入断路器隔离开关串2
    (initget 3 "Y N")
    (setq ANSWERB (getkword "\n需要上部串吗?(Y/N): "))
    (if        (= ANSWERB "Y")
      (progn
        (setq NCT (getint "\n请输入上部串个数: "))
        (prompt "请在母线W1的上找上部串的插入基点: ")
        (repeat        NCT
          (setq P22 (getpoint "\n 请找第N个块的插入基点: "))
          (command "insert" "c:\\song\\c9.dwg" P22 BL BL "" "")
        )
      )
    )
    ;;插入断路器隔离开关串3
    (initget 3 "Y N")
    (setq ANSWERC (getkword "\n需要下部串吗?(Y/N): "))
    (if        (= ANSWERC "Y")
      (progn
        (setq NCT (getint "\n请输入下部串个数: "))
        (prompt "\n请在母线W1的上找下部串的插入基点: ")
        (repeat        NCT
          (setq P22 (getpoint "\n 请找第N个块的插入基点: "))
          (command "insert" "c:\\song\\c10.dwg" P22 BL BL "" "")
        )
      )
    )
)
)
页: [1]
查看完整版本: 紧急!!!请问有谁能帮帮我解决这样一个问题,多谢!