Entmake属性块
嘿伙计们,如何使用前缀、后缀和点号为该例程生成属性块
附加文件以供块参考
标记。图纸
(defun c:test (/ *error* cmh file hd wp export c)
(defun *error* (msg)
(if cmh(setvar 'cmdecho cmh))
(and att(setvar 'attreq att))
(and attd(setvar 'attdia attd))
(and file (close file))
(cond
((not msg))
((member msg '("Function cancelled" "quit / exit abort")))
((princ (strcat "\nError:" msg)))
)
(princ)
)
(setq cmh(getvar 'cmdecho))
(setq att(getvar 'attreq))
(setq attd(getvar 'attdia))
(setvar 'attreq 1)
(setvar 'attdia 0)
(setvar 'cmdecho 0)
(setq suff(getstring t (strcat "\nEnter Prefix:< " (getvar 'users4) " >:")))
(if (or (= suff nil) (= suff ""))
(setq suff(getvar 'users4))
)
(setqpre (getstring t (strcat"\nEnter Suffix:< "(getvar 'users5)" >:")))
(if (or (= pre nil) (= pre ""))
(setq pre(getvar 'users5))
)
(setq c 1)
(setq start(getint (strcat "\nEnter Starting No < " (rtos (getvar 'useri1) 2 0) " >:")))
(if (or (= start "") (= start nil))
(setq start(getvar 'useri1))
)
(setq file(open "C:\\" "w"))
(setq hd(strcat "SL.No." "," "Easting(m)" "," "Northing(m)" "," "Tag Name"))
(write-line hd file)
(while (setq wp(getpoint (strcat"\nPick Location to Create Tag Number < " suff (rtos start 2 0) pre ">:")))
(setq export(strcat (rtos c 2 0) "," (rtos (car wp)) "," (rtos (cadr wp)) "," (strcat suff (rtos start 2 0) pre)))
(write-line export file)
(princ "\nWriting Co-ordinate to csv file")
;;here i want to insert attribute block;;;
(setq start(1+ start))
(setq c(1+ c))
)
(close file)
(setvar 'useri1 start)
(setvar 'users4 suff)
(setvar 'users5 pre)
(*error* nil)
(princ)
) 但在用于插入之前,必须定义块:
要定义:
(entmake '((0 . "BLOCK") (2 . "NodCond") (70 . 2) (8 . "0") (10 0 0 0) ; Isersion Point
(4 . " Description: NodCond.\n\n Made by Costin Bosneag"))) ;_ end of e
(entmake (list '(0 . "CIRCLE") '(8 . "0") '(10 0 0 0) (cons 40 radius)) ) ;_ end of e
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(6 . "Continuous")
'(8 . "0") '(43 . 0) '(90 . 2); 90 number of vertices
'(10 0 0) '(10 0 0) ) ; 70 = closed pline(70 . 1) (list 10 x y) ) ;_ end of e
; 1=The default value ; 2 =Tag ; 3 =Promt
(entmake (list '(0 . "ATTDEF") (cons 8 layer) '(10 0 0 0) '(70 . 0) '(1 . "Default Value") '(2 . "Prefix")
'(3 . "Get Prefix :") (cons 40 htx) (list 11 x y 0) '(74 . 2)) )
.....
(entmake '((0 . "ENDBLK")) ) ;_ end of e(8 . "0")
插入:
(setq scb (getreal "\n GetScaleforInsersionBlock:"))
(setq lisbx (cons 41 scb)lisby (cons 42 scb)lisbz (cons 43 scb) ) ;_ end of setq
; 41= X scale ; 42 = Y scale ; 43 = Z scale ;
(entmake (list '(0 . "INSERT") '(2 . "NodCond") '(8 . "Insert Layer") '(66 . 1) (list 10 x y 0) lisbxlisbylisbz) ) ; insert Block
(entmake (list '(0 . "ATTRIB") '(10 0 0 0) (cons 8 layer) (cons 1 text) '(2 . "tag") (cons 40 htx) '(70 . 0)(list 11 x y 0) '(72 . 0) '(74 . 2)))
.... Att 2 , Att 3 , .....
(entmake '((0 . "SEQEND")) ) ; End Insert Block ! '(8 . "cod")
@gS7
您知道系统变量用户不保存在DWG文件中吗? GP Useri1-5 userr1-5 users1-5所有有效的SETVAR和保存在dwg中。
用户1-5未保存,我不知道Autodesk为什么这个选择。
好的,谢谢你的更正,停止使用userr&我现在已经去字典了,当我认为它有效时,字典并不难使用 @Costinbos77非常感谢 很高兴,还有一次。
页:
[1]