将属性添加到LIS中的块
使用ENTMAKE“attdef”向块添加属性时出错。我做错了什么?
;makes a block and inserts to drawing
(defun C:test_blk()
(setq x 4 y 4)
(setq ot 0.3 )
(if (= ct nil) (setq ct 1))
(setvar "CMDECHO" 0)
(and
(not (tblsearch "BLOCK"
(setq blk_nm (strcat "SP" (rtos ct 2 2)))))
(entmake (list (cons 0 "BLOCK")
(cons 2 blk_nm)
(list 10 0 0 0)
(cons 70 0)))
(entmake (list (cons 0 "3DFACE")(cons 8 "0")
(list 10 0 0 0) ;First corner
(list 11 x 0 0) ;Second corner
(list 12 x y 0) ;Third corner
(list 13 0 y 0))) ; Fourth corner
(entmake (list (cons 0 "TEXT") ;***
(cons 1 "P10") ;Default value (the string itself)
(cons 6 "BYLAYER")
(cons 7 "STANDARD") ;Text style name
(cons 8 "0")
(cons 10 (list (+ ot) ot 0.0)) ;First alignment point
;(cons 11 (list 0.0 0.0 0.0)) ;***
(cons 39 0.0)
(cons 40 1.5) ;Text height
(cons 41 1.0) ;Relative X scale factor
(cons 50 0.0) ;Text rotation
(cons 51 0.0) ;Oblique angle (
(cons 62 256)
(cons 210 (list 0.0 0.0 1.0))))
;;;(entmake (list (cons 0 "ATTDEF") ;
;;; (cons 8 "0")
;;; (cons 10 (list ot (+ y ot) 0)) ;Text start point
;;; (cons 40 2) ;Text height
;;; (cons 1 "55") ;Default value (string)
;;; (cons 2 "TAGNAME") ;Attribute tag (string; cannot contain spaces)
;;; (cons 70 0)
;;; (cons 73 0)
;;; (cons 50 0) ;Text rotation (optional; default = 0)
;;; (cons 41 1) ;Relative X scale factor
;;; (cons 51 0)
;;; (cons 7 "STANDARD") ;***
;;; (cons 71 0)
;;; (cons 72 0)
;;; ;(cons 11 (list 0 0 0)) ;Alignment point
;;; (cons 210 (list 0 0 1));Extrusion direction.
;;; (cons 74 0)
;;; (cons 62 256)
;;; (cons 39 0)
;;; (cons 6 "BYLAYER")))
(entmake (list (cons 0 "ENDBLK")(cons 8 "0"))))
(setq blk_rh (entlast))
(while (eq blk_rh (entlast))
(command "_.INSERT" blk_nm))
(setq ct (+ ct 1))
);defun 它很好吃。
你能粘贴错误回复吗?
当做 查看块头调用的组70。如果遵循变量属性,则应设置2位。
此外,小数是无效的块名字符。(rtos ct 2 2)包括一个小数。
这些至少是一开始-大卫 将块插入dwg I后,键入“ATTEDIT”并选择块-没有可编辑的属性。
谢谢David-大部分代码来自您在沼泽中的帖子。
固定entmake块:
(cons 70 2)
仍然需要让属性工作。 下面的代码似乎有效,但并不令人满意。
ENTMAKE attdef代码3要求键盘输入,而我希望它是在LISP(计数器)中生成的变量。
有没有可能使用ENTMAKE,或者我必须寻找其他解决方案?
(defun c:test_blk ()
(setq x 4 y 4)
(setq ot 0.3 )
(if (= ct nil) (setq ct 1))
;BLOCK Header definition:
(entmake '((0 . "BLOCK")
(2 . "blk_nm")
(70 . 2)
(10 0.0 0.0 0.0)))
;POINT marker definition:
(entmake '((0 . "POINT")
(8 . "0")
(10 0.0 0.0 0.0)
(210 0.0 0.0 1.0)
(50 . 0.0)))
(entmake (list (cons 0 "3DFACE")(cons 8 "0")
(list 10 0 0 0) ;First corner
(list 11 x 0 0) ;Second corner
(list 12 x y 0) ;Third corner
(list 13 0 y 0))) ; Fourth corner
;Text ATTRIBUTE definition:
(entmake
'((0 . "ATTDEF")
(8 . "0")
(10 0.3 4.3 0.0 ) ;First alignment point
(1 . "")
(2 . "num");Tag string (cannot contain spaces)
(3 . "number ??");Prompt string
(40 . 2.0)
(41 . 1.0)
(50 . 0.0)
(70 . 0)
(71 . 0)
(72 . 0)
(73 . 2))
)
;BLOCK's ending definition:
(entmake '((0 . "ENDBLK")))
(command "_.INSERT" blk_nm)
)
试试这个
(entmake
(list
(cons 0 "ATTDEF")
(cons 8 0)
etc...
(cons 3 variable);variable should be string
etc.
这可能会为您指明正确的方向:
(defun GenerateBlock ( name pt )
(if (not (tblsearch "BLOCK" name))
(progn
(entmake
(list
(cons 0 "BLOCK")
(cons 2 name)
(cons 70 2)
(cons 10 '(0. 0. 0.))
)
)
(entmake
(list
(cons 0 "POINT")
(cons 8 "0")
(cons 10 '(0. 0. 0.))
)
)
(entmake
(list
(cons 0 "3DFACE")
(cons 10 '(0. 0. 0.))
(cons 11 '(4. 0. 0.))
(cons 12 '(4. 4. 0.))
(cons 13 '(0. 4. 0.))
)
)
(entmake
(list
(cons 0 "ATTDEF")
(cons 8 "0")
(cons 10 '(0.3 4.3 0.0))
(cons 70 0)
(cons 1 "")
(cons 2 "NUM")
(cons 3 "Number: ")
(cons 40 2.0)
)
)
(entmake
(list
(cons 0 "ENDBLK")
(cons 8 "0")
)
)
)
)
(entmake
(list
(cons 0 "INSERT")
(cons 2 name)
(cons 10 pt)
(cons 66 1)
)
)
(entmake
(list
(cons 0 "ATTRIB")
(cons 10 pt)
(cons 1 "YourCounter")
(cons 2 "NUM")
(cons 40 2.0)
(cons 70 0)
)
)
(entmake
(list
(cons 0 "SEQEND")
)
)
)
谢谢李,
我会试试的。
页:
[1]