本帖最后由 工法 于 2013-1-3 21:49 编辑
(defun C:hh( )
(setq v1 (getvar "cmdecho") )
(setq v2 (getvar "osmode") )
(setq mm (getpoint "\n选择第一个点:"))
(prompt "\nthe point is GJ or JJ.Enter gj or jj : ")
(setq ans(getstring))
(setq nn (getpoint "\n选择第二个点:"))
(prompt "\nthe point is GJ or JJ.Enter gj or jj : ")
(setq ane(getstring))
(setq angle1 (angle mm nn) )
(if(= ans "gj")
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq p1(polar mm angle1 100))
(setq p2(polar p1 angle1 300))
(setq p3(polar p1 (+ (/ pi 2) angle1 ) 225))
(setq p4(polar p1 (+ (/ (* 3 pi) 2) angle1 ) 225))
(command "pline" p2 "w" 0 0 p3 p4 "c" " ")
(command "hatch" "solid" (entlast) "")
(command "_chprop" (entlast) "" "c" 7 "" )
)
)
(if(= ans "jj")
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq p5(polar mm angle1 100))
(setq p6(polar p5 angle1 300))
(setq p7(polar p6 (+ (/ pi 2) angle1 ) 225))
(setq p8(polar p6 (+ (/ (* 3 pi) 2) angle1) 225))
(command "pline" p5 "w" 0 0 p7 p8 "C" " ")
)
)
;第一点的约束情况已经完成
(if(= ane "gj")
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq pp1(polar nn (+ pi angle1) 100))
(setq pp2(polar pp1 (+ pi angle1) 300))
(setq pp3(polar pp1 (+ (/ pi 2) angle1 ) 225))
(setq pp4(polar pp1 (+ (/ (* 3 pi) 2) angle1) 225))
(command "pline" pp2 "w" 0 0 pp3 pp4 "C" " ")
(command "hatch" "solid" (entlast) "")
(command "_chprop" (entlast) "" "c" 7 "" )
)
)
(if(= ane "jj")
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq pp5(polar nn ( + pi angle1) 100))
(setq pp6(polar pp5 (+ pi angle1) 300))
(setq pp7(polar pp6 (+ angle1 (/ pi 2) ) 225))
(setq pp8(polar pp6 (+ angle1 (/ (* 3 pi) 2) ) 225))
(command "pline" pp5 "w" 0 0 pp7 pp8 "C" " ")
)
)
;第二点的约束情况已经完成
(if (and (= ans "jj") (= ane "gj") )
(command "pline" p6 "W" 150 150 pp1 " ")
)
;一端铰接,一端刚接情况
(if (and (= ans "jj") (= ane "jj") )
(command "pline" p6 "W" 150 150 pp6 " ")
)
;两端铰接情况
(if (and (= ans "gj") (= ane "jj") )
(command "pline" p1 "W" 150 150 pp6 " ")
)
;一端刚接,一端铰接情况
(if (and (= ans "gj") (= ane "gj") )
(command "pline" p1 "W" 150 150 pp1 " ")
)
;两端刚接情况
(setvar "cmdecho" v1)
(setvar "osmode" 7)
(princ )
)
(prompt "****<<C:hh>>*****")
(princ )
CAD运行时,对象捕捉总是自动关闭,求原因?
网友答: 不错的小程序,提示有点烦琐了,直接录入00 01 10 11 来区分钢铰接,一次搞定。或选 1 2 3 4选项。网友答: 我也有楼上的要求,求大师网友答: 挺好玩的 小程序,不错网友答:
网友答:
Z版的帮助总是那么及时,路过,帮顶一下!网友答:
Z版主真大热心人!!!帮顶网友答:
小妹在此感谢了,版主太好了
网友答:
(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
,可以用什么函数指定呢?网友答: 恳请高手指点,在线等。。。网友答:




(defun C:hh( )
(setq v1 (getvar "cmdecho") )
(setq v2 (getvar "osmode") )
(setq mm (getpoint "\n选择第一个点:"))
(prompt "\nthe point is GJ or JJ.Enter gj or jj : ")
(setq ans(getstring))
(setq nn (getpoint "\n选择第二个点:"))
(prompt "\nthe point is GJ or JJ.Enter gj or jj : ")
(setq ane(getstring))
(setq angle1 (angle mm nn) )
(if(= ans "gj")
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq p1(polar mm angle1 100))
(setq p2(polar p1 angle1 300))
(setq p3(polar p1 (+ (/ pi 2) angle1 ) 225))
(setq p4(polar p1 (+ (/ (* 3 pi) 2) angle1 ) 225))
(command "pline" p2 "w" 0 0 p3 p4 "c" " ")
(command "hatch" "solid" (entlast) "")
(command "_chprop" (entlast) "" "c" 7 "" )
)
)
(if(= ans "jj")
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq p5(polar mm angle1 100))
(setq p6(polar p5 angle1 300))
(setq p7(polar p6 (+ (/ pi 2) angle1 ) 225))
(setq p8(polar p6 (+ (/ (* 3 pi) 2) angle1) 225))
(command "pline" p5 "w" 0 0 p7 p8 "C" " ")
)
)
;第一点的约束情况已经完成
(if(= ane "gj")
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq pp1(polar nn (+ pi angle1) 100))
(setq pp2(polar pp1 (+ pi angle1) 300))
(setq pp3(polar pp1 (+ (/ pi 2) angle1 ) 225))
(setq pp4(polar pp1 (+ (/ (* 3 pi) 2) angle1) 225))
(command "pline" pp2 "w" 0 0 pp3 pp4 "C" " ")
(command "hatch" "solid" (entlast) "")
(command "_chprop" (entlast) "" "c" 7 "" )
)
)
(if(= ane "jj")
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq pp5(polar nn ( + pi angle1) 100))
(setq pp6(polar pp5 (+ pi angle1) 300))
(setq pp7(polar pp6 (+ angle1 (/ pi 2) ) 225))
(setq pp8(polar pp6 (+ angle1 (/ (* 3 pi) 2) ) 225))
(command "pline" pp5 "w" 0 0 pp7 pp8 "C" " ")
)
)
;第二点的约束情况已经完成
(if (and (= ans "jj") (= ane "gj") )
(command "pline" p6 "W" 150 150 pp1 " ")
)
;一端铰接,一端刚接情况
(if (and (= ans "jj") (= ane "jj") )
(command "pline" p6 "W" 150 150 pp6 " ")
)
;两端铰接情况
(if (and (= ans "gj") (= ane "jj") )
(command "pline" p1 "W" 150 150 pp6 " ")
)
;一端刚接,一端铰接情况
(if (and (= ans "gj") (= ane "gj") )
(command "pline" p1 "W" 150 150 pp1 " ")
)
;两端刚接情况
(setvar "cmdecho" v1)
(setvar "osmode" 7)
(princ )
)
(prompt "****<<C:hh>>*****")
(princ )
CAD运行时,对象捕捉总是自动关闭,求原因?
网友答: 不错的小程序,提示有点烦琐了,直接录入00 01 10 11 来区分钢铰接,一次搞定。或选 1 2 3 4选项。网友答: 我也有楼上的要求,求大师网友答: 挺好玩的 小程序,不错网友答:

- (defun C:hh ()
- (setq v1 (getvar "cmdecho"))
- (setq v2 (getvar "osmode"))
- (setvar "cmdecho" 0)
- (setq mm (getpoint "\n选择第一个点:"))
- (setq ans (getstring "\nthe point is GJ or JJ.Enter gj or jj : "))
- (setq nn (getpoint "\n选择第二个点:"))
- (setq ane(getstring "\nthe point is GJ or JJ.Enter gj or jj : "))
- (setq angle1 (angle mm nn))
- (setvar "osmode" 0)
- (if(= ans "gj") (progn
- (setq p1(polar mm angle1 100))
- (setq p2(polar p1 angle1 300))
- (setq p3(polar p1 (+ (/ pi 2) angle1) 225))
- (setq p4(polar p1 (+ (/ (* 3 pi) 2) angle1) 225))
- (command "pline" p2 "w" 0 0 p3 p4 "c" "")
- (command "hatch" "solid" (entlast) "")
- (command "_chprop" (entlast) "" "c" 7 "")
- ))
- (if(= ans "jj") (progn
- (setq p5(polar mm angle1 100))
- (setq p6(polar p5 angle1 300))
- (setq p7(polar p6 (+ (/ pi 2) angle1 ) 225))
- (setq p8(polar p6 (+ (/ (* 3 pi) 2) angle1) 225))
- (command "pline" p5 "w" 0 0 p7 p8 "C" "")
- ))
- ;第一点的约束情况已经完成
- (if(= ane "gj") (progn
- (setq pp1(polar nn (+ pi angle1) 100))
- (setq pp2(polar pp1 (+ pi angle1) 300))
- (setq pp3(polar pp1 (+ (/ pi 2) angle1 ) 225))
- (setq pp4(polar pp1 (+ (/ (* 3 pi) 2) angle1) 225))
- (command "pline" pp2 "w" 0 0 pp3 pp4 "C" "")
- (command "hatch" "solid" (entlast) "")
- (command "_chprop" (entlast) "" "c" 7 "" )
- ))
- (if(= ane "jj") (progn
- (setq pp5(polar nn (+ pi angle1) 100))
- (setq pp6(polar pp5 (+ pi angle1) 300))
- (setq pp7(polar pp6 (+ angle1 (/ pi 2)) 225))
- (setq pp8(polar pp6 (+ angle1 (/ (* 3 pi) 2)) 225))
- (command "pline" pp5 "w" 0 0 pp7 pp8 "C" "")
- ))
- ;第二点的约束情况已经完成
- (if (and (= ans "jj") (= ane "gj"))
- (command "pline" p6 "W" 150 150 pp1 "")
- )
- ;一端铰接,一端刚接情况
- (if (and (= ans "jj") (= ane "jj"))
- (command "pline" p6 "W" 150 150 pp6 "")
- )
- ;两端铰接情况
- (if (and (= ans "gj") (= ane "jj"))
- (command "pline" p1 "W" 150 150 pp6 "")
- )
- ;一端刚接,一端铰接情况
- (if (and (= ans "gj") (= ane "gj"))
- (command "pline" p1 "W" 150 150 pp1 "")
- )
- ;两端刚接情况
- (setvar "osmode" v2)
- (setvar "cmdecho" v1)
- (princ)
- )
- (prompt "****<<C:hh>>*****")
- (princ)
网友答:
工法 发表于 2013-1-4 13:21
小妹在此感谢了,版主太好了
(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
,可以用什么函数指定呢?网友答: 恳请高手指点,在线等。。。网友答:




