;;;==================================================================
;;;(gxl-dxf ent i )取出图元索引i对应的值
;;;==================================================================
(defun gxl-dxf (ent i)
(if (= (type ent) 'ename)
(setq ent (entget ent))
)
(cdr (assoc i ent))
)
;;;==================================================================
;;;(gxl-CH_Ent ent i pt) 用新值pt更新图元ent索引i对应的值
;;;==================================================================
(defun gxl-CH_Ent (ent i pt / en)
(if (assoc i (setq en (entget ent)))
(setq en (subst (cons i pt) (assoc i en) en))
(setq en (append en (list (cons i pt))))
)
(entmod en)
)
;;删除表中第N个元素
(defun gxl-removeNth (index lst / c rtn lst1)
(if (>= index (length lst)) ;_ index 越界
lst
(if (< index (/ (length lst) 2)) ;_ index位于前半截
(progn
(setq c -1 lst1 lst)
(vl-some '(lambda (x) (if (equal index (setq c (1+ c))) t (progn (setq rtn (cons x rtn) lst1 (cdr lst1)) nil))) lst)
(append (reverse rtn) (cdr lst1))
)
(progn ;_ index位于后半截
(setq index (- (length lst) index 1) lst (reverse lst))
(setq c -1 lst1 lst)
(vl-some '(lambda (x) (if (equal index (setq c (1+ c))) t (progn (setq rtn (cons x rtn) lst1 (cdr lst1)) nil))) lst)
(reverse (append (reverse rtn) (cdr lst1)))
)
)
)
)
(defun gxl-massoc( d li / a ls )
(setq ls '())
(while (assoc d li)
(progn
(setq a (assoc d li))
(setq ls (cons (list (cadr a) (caddr a)) ls))
(setq li (xdlsp_list_remove li a))
)
)
(reverse ls)
)
;输出50个空格
;(gxl-Str-Space 50) " "
;(gxl-Str-Space -1)
(defun gxl-Str-Space ( d / a )
(setq a "")
(if (> d 0)
(repeat d
(setq a (strcat a " " ))
)
)
a
)