- 积分
- 11693
- 明经币
- 个
- 注册时间
- 2011-9-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2014-5-6 17:50:03
|
显示全部楼层
73哥程序(defun SstoEs(ss / a en lst)
(if ss(progn(setq a -1)
(while(setq en(ssname ss(setq a(1+ a))))
(setq lst(cons en lst)))))
lst)
(defun subtotals(lst m ns / myfun a b c);;对lst以子表第m项为关键字进行分类,ns为整数时记录第ns项、为表(2 3)记录表中指定的项、为空记录关键字以外所有项
(cond((=(type ns)'LIST)(defun myfun(x)(list(mapcar'(lambda(y)(nth y x))ns))))
((=(type ns)'INT)(defun myfun(x)(LIST(NTH ns x))))
(t(defun myfun(x)(list(vl-remove c x)))))
(foreach x lst
(setq a(if(setq c(nth m x)b(assoc c a))
(subst(append b(myfun x))b a)
(append a(list(append(list c)(myfun x))))))))
(defun c:tt1()
(setq blc (getint "\n请输入比例尺1:"))
(setvar 'userr1 blc);设置比例尺
; (setq zg(* 0.002 blc));字高
(setq scale (* 0.001 blc));缩放比例
(foreach x(vl-remove-if'(LAMBDA(x)(<(length x)3))(SUBTOTALS(mapcar'(lambda(x)(setq p(cdr(assoc 10(entget x))))
(list(list(car p)(cadr p))(last p)))(sstoes(ssget"X"'((8 . "GCD")))))0 1))
(gxl-cs:gcd x scale))
(princ)
)
;;by Gu_xl
(defun gxl-cs:gcd (inspt scale / pt blkdef obj);展高程点函数(inspt:((x y)h1 h2)),scale:缩放比例)
(setvar "CMDECHO" 0)
(command "layer" "m" "GCD" "c" "1" "" "L" "CONTINUOUS" "" "")
(regapp "SOUTH")
;;;检查字体 "HZ" 是否存在
(if(not(tblobjname "style" "HZ"))(command "style" "HZ" "rs.shx,hztxt.shx" 0 1 0 "" "" ""))
;;;检查是否存在高程点图块定义
(if(not(tblobjname "block" "GC200"))
(progn
(setq obj
(vla-AddPolyline
(vla-Add(vla-get-Blocks(vla-get-ActiveDocument(vlax-get-acad-object)))(vlax-3D-point '(0 0 0)) "GC200")
(vlax-make-variant(vlax-safearray-fill(vlax-make-safearray vlax-vbdouble (cons 0 5))'(-0.2 0 0 0.2 0 0)))))
(vla-SetBulge obj 0 1)(vla-SetBulge obj 1 1)
(vla-put-Closed obj :vlax-true)
(vla-put-ConstantWidth obj 0.4)))
;;;插入块
(entmake (list
'(0 . "INSERT")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockReference")
'(66 . 1);;;属性跟随标志,1跟随,0不跟随
'(2 . "GC200")
(cons 10(setq pt(append(car inspt)(list(cadr inspt)))))
(cons 41 scale)
(cons 42 scale)
(cons 43 scale)
(list -3 '("SOUTH" (1000 . "202101")))))
;;;插入属性
(entmake (list
'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
(cons 62 1)
(cons 10 (setq pt(polar pt 0(* 1.2 scale))))
(cons 40 (* 2.0 scale))
(cons 50 0)
(cons 41 0.8)
(cons 51 0)
(cons 1 (rtos(cadr inspt)2 3))
(cons 7 "HZ")
(cons 72 0)
(cons 11 pt)
'(100 . "AcDbAttribute")
(cons 2 "height1")
(cons 70 0)
(cons 74 1)
))
(entmake (list
'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
(cons 62 2)
(cons 10 pt)
(cons 40 (* 2.0 scale))
(cons 50 0)
(cons 41 0.8)
(cons 51 0)
(cons 1 (rtos(last inspt)2 3))
(cons 7 "HZ")
(cons 72 0)
(cons 11 pt)
'(100 . "AcDbAttribute")
(cons 2 "height2")
(cons 70 0)
(cons 74 3)
))
(entmake (list
'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
(cons 62 3)
(cons 10 (setq pt(polar(car inspt)pi(* 1.2 scale))))
(cons 40 (* 2.0 scale))
(cons 50 0)
(cons 41 0.8)
(cons 51 0)
(cons 1 (rtos(-(cadr inspt)(last inspt))2 3))
(cons 7 "HZ")
(cons 72 2)
(cons 73 2)
(cons 11 pt)
'(100 . "AcDbAttribute")
(cons 2 "height2")
(cons 70 0)
(cons 74 2)
))
;;;结束标志
(entmake '((0 . "SEQEND")))
(princ)
) |
|