一个是可以求某一图层上封闭实体的形心,程序根据你输入的图层自动选择该层上所有实体,
;;;再根据你点取的点求取点所在周边封闭实体的形心并显示在“point”图层上,如下:
(defun ez (/ f xxx xxy xxx1 xxy1 xxx2 xxy2 cep oldom oldcm oldbm oldfd oldlp oldla pt en ptlist ss la enpt)
(prompt "形心求解器修改版 0.2 2004年6月26日")
(command "undo" "group")
(setq oldla (getar "CLAYER"))
(setq oldcm (getar "CMDECHO"))
(setq oldfd (getar "FILEDIA"))
(setq oldlp (getar "LUPREC"))
(setq oldom (getar "OSMODE"))
(setq oldbm (getar "BLIPMODE"))
(setq oldpm (getar "PDMODE"))
(setar "CMDECHO" 0)
(setar "FILEDIA" 0)
(setar "LUPREC" 8)
(setar "OSMODE" 0)
(setar "BLIPMODE" 1)
(if (not laname) (setq laname "c-h"))
(setq la (getstring (strcat "n请输欲求形心的实体所在图层名<" laname "或当前层>:")))
(if (= la "") (setq la laname) (setq laname la))
(if (tblsearch "LAYER" la)
(setq ss (ssget "X" (list (cons 8 la))))
(setq ss (ssget "X"))
)
(while
(setq pt (getpoint "n请点取欲求形心的封闭实体内部点:"))
(setq ptlist (append ptlist (list pt)))
)
(if ss
(progn
(if ptlist
(progn
(foreach pt ptlist
(command "-boundary" "a" "o" "r" "b" "n" ss "" "" pt "")
(setq en (entget (entlast)))
(if (equal (assoc 0 en) '(0 . "REGION"))
(progn
(command "massprop" "l" "" "y" "c:/ZZX.mpr")
(command "_erase" "l" "")
(setq f (open "c:/ZZX.mpr" "r"))
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(setq xxx (read-line f))
(setq xxy (read-line f))
(close f)
(setq xxx1 (substr xxx 25 20))
(setq xxy1 (substr xxy 25 20))
(setq xxx2 (atof xxx1))
(setq xxy2 (atof xxy1))
(setq cep (list xxx2 xxy2 0))
(setq enpt (entmake (list (cons 0 "point")(cons 8 "point") (cons 10 cep))))
);;;end progn
(prompt "n没有选到符合求形心条件的东东,退出!")
);;;end if
);;;end foreach
(if enpt
(progn
(command "-layer" "on" "point" "")
(if (/= (getar "pdmode") 3) (setar "pdmode" 3))
(command "_redraw")
(princ)
(prompt "nn 多义线的形心已用点显示在point图层,如果有必要请定义过点的形式以显示得更好")
);;;end progn
);;;end if
);;;end progn
(prompt "n 没有选到任何点,退出!")
);;;end if ptlist
);;;end progn
(prompt "n没有选到符合求形心条件的东东,退出!")
);;;end if ss
(setar "FILEDIA" oldfd)
(setar "LUPREC" oldlp)
(setar "CMDECHO" oldcm)
(setar "OSMODE" oldom)
(setar "CLAYER" oldla)
(setar "BLIPMODE" oldbm)
(setar "PDMODE" oldpm)
(command "undo" "end")
(princ)
);;;end defun
;;;再根据你点取的点求取点所在周边封闭实体的形心并显示在“point”图层上,如下:
(defun ez (/ f xxx xxy xxx1 xxy1 xxx2 xxy2 cep oldom oldcm oldbm oldfd oldlp oldla pt en ptlist ss la enpt)
(prompt "形心求解器修改版 0.2 2004年6月26日")
(command "undo" "group")
(setq oldla (getar "CLAYER"))
(setq oldcm (getar "CMDECHO"))
(setq oldfd (getar "FILEDIA"))
(setq oldlp (getar "LUPREC"))
(setq oldom (getar "OSMODE"))
(setq oldbm (getar "BLIPMODE"))
(setq oldpm (getar "PDMODE"))
(setar "CMDECHO" 0)
(setar "FILEDIA" 0)
(setar "LUPREC" 8)
(setar "OSMODE" 0)
(setar "BLIPMODE" 1)
(if (not laname) (setq laname "c-h"))
(setq la (getstring (strcat "n请输欲求形心的实体所在图层名<" laname "或当前层>:")))
(if (= la "") (setq la laname) (setq laname la))
(if (tblsearch "LAYER" la)
(setq ss (ssget "X" (list (cons 8 la))))
(setq ss (ssget "X"))
)
(while
(setq pt (getpoint "n请点取欲求形心的封闭实体内部点:"))
(setq ptlist (append ptlist (list pt)))
)
(if ss
(progn
(if ptlist
(progn
(foreach pt ptlist
(command "-boundary" "a" "o" "r" "b" "n" ss "" "" pt "")
(setq en (entget (entlast)))
(if (equal (assoc 0 en) '(0 . "REGION"))
(progn
(command "massprop" "l" "" "y" "c:/ZZX.mpr")
(command "_erase" "l" "")
(setq f (open "c:/ZZX.mpr" "r"))
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(read-line f)
(setq xxx (read-line f))
(setq xxy (read-line f))
(close f)
(setq xxx1 (substr xxx 25 20))
(setq xxy1 (substr xxy 25 20))
(setq xxx2 (atof xxx1))
(setq xxy2 (atof xxy1))
(setq cep (list xxx2 xxy2 0))
(setq enpt (entmake (list (cons 0 "point")(cons 8 "point") (cons 10 cep))))
);;;end progn
(prompt "n没有选到符合求形心条件的东东,退出!")
);;;end if
);;;end foreach
(if enpt
(progn
(command "-layer" "on" "point" "")
(if (/= (getar "pdmode") 3) (setar "pdmode" 3))
(command "_redraw")
(princ)
(prompt "nn 多义线的形心已用点显示在point图层,如果有必要请定义过点的形式以显示得更好")
);;;end progn
);;;end if
);;;end progn
(prompt "n 没有选到任何点,退出!")
);;;end if ptlist
);;;end progn
(prompt "n没有选到符合求形心条件的东东,退出!")
);;;end if ss
(setar "FILEDIA" oldfd)
(setar "LUPREC" oldlp)
(setar "CMDECHO" oldcm)
(setar "OSMODE" oldom)
(setar "CLAYER" oldla)
(setar "BLIPMODE" oldbm)
(setar "PDMODE" oldpm)
(command "undo" "end")
(princ)
);;;end defun
使用了一下,感觉不错
在材料力学中应该有较大用处
相关文章
- 2021-08-22AutoCAD 2013应用与开发系列中文版AutoCAD 2013机械图
- 2021-08-20AutoCAD 2012建筑图形设计中文版 [施勇 编著] 2012年P
- 2021-08-18图形图像设计专家Maya金典案例教程PDF下载
- 2021-08-12AutoCAD 2012建筑图形设计中文版 [施勇 编著] 2012年P
- 2021-08-08中文版AutoCAD 2013建筑图形设计 [施勇,胡中杰 编著] 2
- 2021-08-07中文版AutoCAD 2014机械图形设计 [崔洪斌 编著] 2014
- 2021-08-07中文版AutoCAD 2014建筑图形设计 [胡中杰,施勇 编著] 2
- 2021-07-27AutoCAD 建筑图形设计与天正建筑TArch工程实践2012中
- 2021-05-05中文版AutoCAD 2010建筑图形设计PDF下载
- 2021-05-05中文版AutoCAD 2011建筑图形设计PDF下载