自贡黄明儒 发表于 2012-3-22 15:23:43

笔记之一

本帖最后由 自贡黄明儒 于 2012-3-22 15:24 编辑

;;1 (getvar "cmdnames")检测正在运行的命令
;;结束在运行的命令
(while (not (equal (getvar "cmdnames") "")) (command nil))

;;2 选择集
;;2.1获取已选对象
(setq ss (ssgetfirst))
;;2.2恢复预选对象
(if (and ss (equal 1 (logand 1 (getvar "pickfirst"))))
(sssetfirst (car ss) (cadr ss))
)
;;2.3将选择集SS设为已选择状态
(sssetfirst nil SS)
;;2.4获取当前激活的选择集,而过滤器则保证从中筛选出符合条件的对象。
(setq SS (ssget "_I" FIL))
;;2.5 用Select之后,(ssget "_P")就可得到这个选择集
(command "._Select" ss1 "")
(setq ss (ssget "_p" '((0 . "*TEXT"))))
;;2.6两选择集相加,之后_p得相加选择集(减"_Remove")
(command "._Select" ss1 "_add" ss2 "")
(setq ss (ssget "_p"))

;;3(b_layer_locked "0"),0层锁后返回T
(defun b_layer_locked (la / na e1)
(setq

自贡黄明儒 发表于 2012-3-22 15:28:00

;;3(b_layer_locked "0"),0层锁后返回T
(defun b_layer_locked (la / na e1)
(setq        na (tblobjname "layer" la)
        e1 (entget na)
)
(equal 4 (logand 4 (cdr (assoc 70 e1))))
)

;;4返回a在表lst中的位置 or nil
(defun position        (a lst / b)
(if (setq b (member a lst))
    (progn (setq b (- (length lst) (length b))))
)
b
)

;;5 关键字a的列表框增加内容
(defun mpoplst (a lst / n)
(start_list a 3)
(setq n 0)
(repeat (length lst)
    (add_list (nth n lst))
    (setq n (+ n 1))
)
(end_list)
)

;;6旋转一个点
;;Rotate 'pnt'点 from a base point of 'p1' and through an angle
;;of 'ang' (in radians)
(defun rotate_pnt (pnt p1 ang /)
(polar p1 (+ (angle p1 pnt) ang) (distance p1 pnt))
)

;;7缩放一个点
;;scale 'pnt' from a base point of 'p1' by a factor of fact
(defun scale_pnt (pnt p1 fact /)
(polar p1 (angle p1 pnt) (* fact (distance p1 pnt)))
)

;;8.1如a为"C:\\Program Files\\AutoCAD 2005\\support\\AlignObject.VLX"
;;返回"AlignObject.VLX"
(defun pstrip (a / b)
(cond        ((setq b (strsea "\\" a)) (setq b b))
        ((setq b (strsea "/" a)) (setq b b))
        (T (setq b (list 0)))
)
(setq a (substr a (+ (last b) 1) (strlen a)))
)

;;8.2去文件名扩展,比如去掉.exe
(defun xstrip (fna / st)
(if (and (setq st (strsea "." fna))
           (<= (- (strlen fna) 3) (last st))
      )
    (setq fna (substr fna 1 (- (last st) 1)))
)
fna
)
(defun strsea (a b / c n)
(cond        ((equal "" a) (setq c nil))
        ((not (equal (type b) (type "1")))
       (progn        (print "!!!!不是字符串!!!!")
                (print b)
                (setq c nil)
       )
        )
        (T
       (progn        (setq n 1)
                (while (>= (+ (- (strlen b) n) 1) (strlen a))
                  (if (equal (substr b n (strlen a)) a)
                  (setq c (append c (list n))
                          n (- (+ n (strlen a)) 1)
                  )
                  )
                  (setq n (+ n 1))
                )
       )
        )
)
c
)
;;8.3
(fnsplitl "C:\\Program Files\\AutoCAD 2004\\acad.exe")
;;返回("C:\\Program Files\\AutoCAD 2004\\" "acad" ".exe")


;;10p1是否在p2 p3线上
(defun what_side (p1 p2 p3 / a dx dx1 dy dy1)
(setq        dx(- (car p3) (car p2))
        dy(- (cadr p3) (cadr p2))
        dx1 (- (car p1) (car p2))
        dy1 (- (cadr p1) (cadr p2))
)
(setq        a (- (* dx dy1) (* dy dx1))
        a (rtos a 2 6)
        a (atof a)
)
(if (not (equal 0.0 a))
    (setq a (/ a (abs a)))
)
a
)

;;11符号Layer,Ltype,Viewx,Style,Block,Appid,Ucs,Dimstyle和Vport列表
;;示例(xyp-get-tblnext "Layer")
(defun xyp-get-tblnext (table-name / lst d)
(while (setq d (tblnext table-name (null d)))
    (setq lst (cons (cdr (assoc 2 d)) lst))
)
(reverse lst)
lst
)

;;12.1 亮显选择集或对象(夹点不显示) 函数
;;;*****************************************
(defun ayEntSSHighLight(SSorEntName / oldGrips)
(setq oldGrips (getvar "Grips"))
(setvar "Grips" 0)
(cond
   ((= (type SSorEntName) 'PICKSET)
    (sssetfirst nil SSorEntName)
   )
   ((= (type SSorEntName) 'ENAME)
    (sssetfirst nil (ssadd SSorEntName (ssadd)))
   )
)
(setvar "Grips" oldGrips)
)
;;12.2
(vla-highlight OBJ 1)
;;12.3
(redraw en 4);不亮显
(redraw en 3);亮显

soly2006 发表于 2012-3-22 15:36:14

鼎!!!!!

logoin 发表于 2012-3-22 19:57:29

好东西,收藏了~~

zhb236623 发表于 2012-4-17 16:14:24

好东东,。…。…。………

lish 发表于 2013-7-4 19:28:01

学习了!!!!!!!!

yaokui25 发表于 2013-7-4 22:26:59

才看到,好东西支持一下
页: [1]
查看完整版本: 笔记之一