(defun c:ff () (setvar "cmdecho" 0) (command "layoff") (setvar "cmdecho" 1) (prin1) ) 选择需要关闭的图层
(defun c:qw () (setvar "cmdecho" 0) (command "layiso") (setvar "cmdecho" 1) (prin1) ) 选择需要隔离的图层
(defun c:tc () (setvar "cmdecho" 0) (command "laymcur") (setvar "cmdecho" 1) (prin1) ) 选择对象为当前图层
(defun c:df () (setvar "cmdecho" 0) (command "ribbon") (setvar "cmdecho" 1) (prin1) ) 打开工具选项栏
(defun c:fd () (setvar "cmdecho" 0) (command "ribbonclose") (setvar "cmdecho" 1) (prin1) ) 关闭工具选项栏
修改图层
(defun C:XG (/ #os1 &k1 #k1 %k1 &kw i %k2)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setq #os1 (getvar "osmode"))
(setvar "osmode" 0)
(setq &k1 (entsel "\n请选择参考图层"))
(if (= &k1 nil)
(princ "\n没有选择参考图层")
)
(if (/= &k1 nil)
(progn
(setq &k1 (car &k1)
#k1 (entget &k1)
%k1 (assoc 8 #k1)
)
(princ "\n请选择需要改变的对象")
(setq &kw (ssget))
(if (= &kw nil)
(princ "\n没有选择对象")
)
(if (/= &kw nil)
(progn
(setq i 0)
(repeat (sslength &kw)
(setq &k1 (ssname &kw i)
#k1 (entget &k1)
%k2 (assoc 8 #k1)
#k1 (subst
%k1
%k2
#k1
)
i (+ i 1)
)
(entmod #k1)
)
(princ "\n改变图层完成")
)
)
)
)
(setvar "osmode" #os1)
(prin1)
)
一键所有填充对象置后显示,CAD2005以上版本适用 By Gu_xl 2014.07.17
(defun C:ZX5 (/ sortents dict lst Doc)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(vl-load-com)
(setq doc
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
(vlax-for blockdef (vla-get-blocks doc)
(cond
(
(not
(VL-CATCH-ALL-ERROR-P
(setq sortents
(VL-CATCH-ALL-APPLY
'vla-item
(list
(setq dict
(vla-GetExtensionDictionary
blockdef
)
)
"ACAD_SORTENTS"
)
)
)
)
)
)
((setq sortents
(VL-CATCH-ALL-APPLY
'vla-AddObject
(list dict "ACAD_SORTENTS" "AcDbSortentsTable")
)
)
)
)
(setq lst nil)
(vlax-for obj blockdef
(if (= "AcDbHatch" (vla-get-objectname obj))
(setq lst (cons obj lst))
)
)
(if lst
(progn
(vla-MoveToBottom
sortents
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbobject
(cons 0 (1- (length lst)))
)
lst
)
)
)
)
)
)
(vla-regen doc :vlax-true)
(princ)
)
以上复制到记事本,以(.lsp)为后缀命名,加载autoLISP到AutoCAD。这几个命令基本上会用到
1.首先,同LZ说的,你OSMODE没弄成0,不过我觉得你出的错在于,你求的角度有问题,程序里你求的是角B,就是b对应着的角,而ATAN的范围是(-PI/2 PI/2),在没判别角的大小时,角B是有可能钝角的,所以就出错了,最好是把ABC按照大小排一下,按你程序里,把b弄成最小的角,就没问题了.2.在程序前面加个判别能否形成三角形的语句,就是最小+次小>最大的那个.
3.程序末尾最好加个(PROMPT"")语句,标明怎么运行这个程序,不然加载了你这个程序不知道怎么打开.
刚才又看了下,发现你setq p3 (polar p1 (* ang1 (/ 180 pi )) c))这一句也有问题,ATAN返回的本来就是弧度值,而polar也是用弧度值的
祝LZ早日学成~ 附程序,还有缺陷,*ERROR*参数没设置,嫌麻烦
(defun c:sbx (/ p1 p2 p3 a b c p h d ang1)
(setq oldos (getvar "osmode"))
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setq p1 (getpoint "请输入基点:"))
(setq a (getdist "\n请输入a=:"))
(setq b (getdist "\n请输入b=:"))
(setq c (getdist "\n请输入c=:"))
(setq c1 (max a b c)
b1 (min a b c)
)
(foreach temp (list a b c)
(if (and (<temp c1) (>temp b1))
(setq a1 temp)
)
)
(if (<(+ a1 b1) c1)
(princ "出错,输入的三边不能组成三角形")
(progn
(setq p (/ (+ a b c) 2))
(setq h (sqrt (/ (* (* 4 p) (- p a) (- p b) (- p c)) (* a1 a1))))
(setq d (sqrt (- (* c1 c1) (* h h))))
(setq ang1 (atan h d))
(setq p3 (polar p1 ang1 c1))
(setq p2 (polar p1 0 a1))
(command "line" p1 p2 p3 "c")
)
)
(setvar "osmode" oldos)
(prin1)
)
(prompt"********************输入sbx以开始程序********************")
(princ)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)