明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1030|回复: 3

求助:关于默认输出的问题 钢框架小程序

[复制链接]
发表于 2013-1-4 13:38:57 | 显示全部楼层 |阅读模式
(prompt  "\nthe two points is GJ GG JG or JJ.Enter gj gg jg or jj : ")
(setq cc(getstring))
(setq ans(substr cc 1 1    )
      ane(substr cc 2 1    )
)

如果从键盘输入的话就按gj gg jg or jj 之一程序可以正常运行,如果键盘不输入,程序默认指定jj
,可以用什么函数指定呢?

请大家帮忙解答啊

发表于 2013-1-4 13:46:36 | 显示全部楼层
鍵盤不輸入,程序默認指定jj
(setq cc(getstring))
(if (= cc "") (setq cc jj))

改用 ustr
more info:
http://www.google.com/search?as_ ... A%2F%2Fbbs.mjtd.com
 楼主| 发表于 2013-1-4 14:24:38 | 显示全部楼层
(defun C:zz( )

(setq v1 (getvar "cmdecho")   )      
(setq v2 (getvar "osmode")    )  



(prompt  "\nthe two points is GJ GG JG or JJ.Enter gj gg jg or jj : ")
(setq cc(getstring))
(if (= cc " " )       (setq cc "jj")
)

(setq ans(substr cc 1 1    )
      ane(substr cc 2 1    )
)


(setq mm (getpoint "\n选择第一个点:"))
(setq nn (getpoint "\n选择第二个点:"))
(setq angle1 (angle mm nn)   )

(setvar "cmdecho" 0)   
(setvar "osmode" 0)  



(if(= ans "g")
  (progn

      (setq p1(polar mm angle1 100))
      (setq p2(polar p1 angle1 300))
      (setq p3(polar p1 (+ (/ pi 2)  angle1 )  150))
      (setq p4(polar p1 (+  (/ (* 3 pi) 2)  angle1 )   150))
      (command "pline" p2 "w" 0 0  p3 p4 "c" " ")
      (command "chprop" (entlast) "" "c" 4 ""  )
      (command "hatch" "solid" (entlast) "")       
      (command "chprop" (entlast) "" "c" 4 ""  )                    

  )
)


(if(= ans "j")
    (progn

     (setq p5(polar mm  angle1 100))
     (setq p6(polar p5  angle1 300))
     (setq p7(polar p6 (+ (/ pi 2) angle1 ) 150))
     (setq p8(polar p6 (+ (/ (* 3 pi) 2)  angle1) 150))
     (command "pline" p5 "w" 0 0  p7 p8 "C" " ")
     (command "chprop" (entlast) "" "c" 4 ""  )

    )
)
;第一点的约束情况已经完成




(if(= ane "g")
(progn

    (setq pp1(polar nn (+ pi  angle1) 100))
    (setq pp2(polar pp1 (+ pi   angle1) 300))
    (setq pp3(polar pp1 (+ (/ pi 2)  angle1 ) 150))
    (setq pp4(polar pp1 (+ (/ (* 3 pi) 2) angle1)  150))
    (command "pline" pp2 "w" 0 0  pp3 pp4 "C"  " ")
    (command "chprop" (entlast) "" "c" 4 ""  )
    (command "hatch" "solid" (entlast) "")       
    (command "chprop" (entlast) "" "c" 4 ""  )
)
)


(if(= ane "j")
    (progn
     
     (setq pp5(polar nn  ( + pi  angle1)  100))
     (setq pp6(polar pp5  (+  pi angle1)  300))
     (setq pp7(polar pp6 (+ angle1  (/ pi 2) )  150))
     (setq pp8(polar pp6 (+ angle1  (/ (* 3 pi) 2) ) 150))
     (command "pline" pp5 "w" 0 0  pp7 pp8 "C"  " ")
     (command "chprop" (entlast) "" "c" 4 ""  )

    )  
)
;第二点的约束情况已经完成






(if (and (= ans "j") (= ane "g")  )
    (progn
      (command "pline" p6   "W" 100 100  pp1 "c"" ")
      (command "chprop" (entlast) "" "c" 4 ""  )  
    )
)   
;一端铰接,一端刚接情况


(if (and (= ans  "j") (= ane  "j")  )
     (progn      
          (command "pline"  p6  "W" 100 100  pp6"c" " ")
          (command "chprop" (entlast) "" "c" 4 ""  )
     )
   
)   
;两端铰接情况

(if (and (= ans "g") (= ane "j")  )   
   (progn
         (command "pline" p1    "W" 100 100  pp6 "c"" ")
         (command "chprop" (entlast) "" "c" 4 ""  )
   )
        
)   
;一端刚接,一端铰接情况


(if (and (= ans "g") (= ane "g")  )
    (progn   
         (command "pline" p1   "W" 100  100   pp1 "c"" ")
         (command "chprop" (entlast) "" "c" 4 ""  )
    )  
      
)   
;两端刚接情况


(setvar "cmdecho" v1)   
(setvar "osmode" v2)




(princ   )
)
(prompt "****精工<<C:zz>>*****")
(princ )




为什么按照默认的运行不了,求解释
 楼主| 发表于 2013-1-4 14:42:46 | 显示全部楼层
解决了,原来是小冒号的问题。多谢版主Andyhon 啦
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-6-2 11:01 , Processed in 0.151350 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表