- 积分
- 13757
- 明经币
- 个
- 注册时间
- 2007-1-15
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 print1985 于 2021-3-2 19:59 编辑
调整行距hj,支持CAD文字、天正单行和多行文字、图块、属性字、天正标高、cad表格、cad尺寸
其中调整天正标高行距非常适合水、暖专业画系统图时,直接复制建筑立面标高来调整行距
部分代码来自论坛,感谢各位大神
技术含量不高,但是水平有限错误难免,如有问题请留言
现在明经不能上传附件 如果下面代码复制不能使用 请到晓东下载
http://bbs.xdcad.net/thread-727738-1-1.html
- ;;调整行距hj 支持CAD文字、天正单行和多行文字、图块、属性字、天正标高、cad表格、cad尺寸
- (setq BGhangju nil)
- (defun c:hj ( / *error* a all b c e hangju1 hangju2 l m n p snap x x0 xyz xyz_new y y0 z)
- (defun *error* (msg) ;错误处理函数
- (if snap (setvar "osmode" snap)) ;恢复捕捉
- (if (< 18 (atoi (substr (getvar "acadver") 1 2))) ;判断CAD版本,高版本用command-s
- (command-s "undo" "e") ;CAD高版本用
- (command "undo" "e") ;低版本用
- )
- (setvar "cmdecho" 1) ;打开命令行提示
- (princ msg)
- )
- (if (setq a (ssget (list (cons 0 "*TEXT,DIMENSION,INSERT,ATTDEF,ACAD_TABLE,TCH_ELEVATION"))))
- (progn
- (setq n (sslength a))
- (setq m 0)
- (while (< m n)
- (setq all (append all (list (entget (ssname a m)))))
- (setq m (1+ m))
- )
- (setq l 0) ;按y坐标降序排列
- (setq m 1)
- (while (< l n)
- (setq b (nth l all))
- (while (< m n)
- (setq c (nth m all))
- (if (> (nth 2 (assoc '10 c)) (nth 2 (assoc '10 b)))
- (progn
- (setq all (subst 'aa (nth l all) all))
- (setq all (subst 'bb (nth m all) all))
- (setq all (subst c 'aa all))
- (setq all (subst b 'bb all))
- (setq b c)
- )
- )
- (setq m (1+ m))
- )
- (setq l (1+ l))
- (setq m (1+ l))
- )
- (setq p (cdr (assoc '10 (car all))))
- (setq hangju2 2000) ;默认行距为2000,自行修改
- (if (or (= BGhangju 0) (= BGhangju nil))
- (if (setq BGhangju (getint (strcat "\n行距<" (rtos hangju2) ">:")))
- (setq hangju2 BGhangju)
- )
- (if (setq hangju1 (getint (strcat "\n行距<" (rtos BGhangju) ">:")))
- (progn
- (setq hangju2 hangju1)
- (setq BGhangju hangju1)
- )
- (setq hangju2 BGhangju)
- )
- )
- (setq x0 (car p))
- (setq y0 (cadr p))
- (setq m 0)
- (setvar "cmdecho" 0) ;关闭命令行提示
- (vl-cmdf "undo" "be") ;命令开始标记
- (setq snap (getvar "osmode")) ;取得捕捉参数
- (setvar "osmode" 0) ;关闭捕捉
- (while (< m n)
- (setq b (nth m all))
- (setq e (cdr (assoc -1 b))) ;图原名
- (setq z (nth 3 (assoc 10 b)))
- (setq x (nth 1 (assoc 10 b)))
- (setq y (nth 2 (assoc 10 b)))
- (setq xyz (list x y z)) ;老坐标
- (setq xyz_new (list x0 y0 z)) ;新坐标
- (vl-cmdf "move" e "" xyz xyz_new) ;移动
- (setq y0 (- y0 hangju2))
- (setq m (1+ m))
- )
- (setvar "osmode" snap) ;打开捕捉
- (vl-cmdf "undo" "e") ;命令结束标记
- (setvar "cmdecho" 1) ;打开命令行提示
- )
- )
- (princ)
- )
|
评分
-
查看全部评分
|