注释比例的创建方法
以下两种是注释比例的方法,都存在错误。第一种保存后才能看到结果。第二种所有都是注释比例。
;(addscale (car(entsel)) "1:2")
(defun AddScale (object scale / DefineNewDictHandle)
(defun MultipleAssoc (key alist / x nlist)
(foreach x alist
(if (eq key (car x))
(setq nlist (cons (cdr x) nlist))
)
)
(reverse nlist)
)
(defun LM:annoscales ( ent / dic enx itm rtn )
(if
(and
(setq enx (entget ent))
(setq dic (cdr (assoc 360 (cdr (member '(102 . "{ACAD_XDICTIONARY") enx)))))
(setq dic (cdr (assoc -1 (dictsearch dic "acdbcontextdatamanager"))))
(setq dic (cdr (assoc -1 (dictsearch dic "acdb_annotationscales"))))
)
(while (setq itm (dictnext dic (not itm)))
(setq rtn (cons (cdr (assoc 300 (entget (cdr (assoc 340 itm))))) rtn))
)
)
(reverse rtn)
)
(defun DefineNewDictHandle(lst / leeter numbre handles retVal)
(foreach letter '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K")
(foreach number '(0 1 2 3 4 5 6 7 8 9)
(setq handles (cons (strcat "*" letter (itoa number)) handles))
))
(setq handles (reverse handles))
(while (member (setq retVal (car handles)) lst) (setq handles (cdr handles)))
retVal
)
(and
(not (member scale (LM:annoscales object)))
(setq enx (entget object))
(setq dicLv1 (cdr (assoc 360 (cdr (member '(102 . "{ACAD_XDICTIONARY") enx)))))
(setq dicLv2 (cdr (assoc -1 (dictsearch dicLv1 "acdbcontextdatamanager"))))
(setq dicLv3 (cdr (assoc -1 (dictsearch dicLv2 "acdb_annotationscales"))))
(setq handle (DefineNewDictHandle (MultipleAssoc 3 (entget diclv3))))
(dictadd dicLv3
handle
(entmakex (list
;((-1 . <图元名: 374da810>)
;单行文字
;;; '(0 . "ACDB_TEXTOBJECTCONTEXTDATA_CLASS")
;;; '(102 . "{ACAD_REACTORS")
;;; (cons 330 dicLv3)
;;; '(102 . "}")
;;; (cons 330 dicLv3)
;;; '(100 . "AcDbObjectContextData")
;;; '(70 . 4)
;;; '(290 . 1)
;;; '(100 . "AcDbAnnotScaleObjectContextData")
;;; (cons 340 (entmakex (list '(0 . "SCALE")
;;; '(102 . "{ACAD_REACTORS")
;;; (cons 330 (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_SCALELIST"))))
;;; '(102 . "}")
;;; (cons 330 (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_SCALELIST"))))
;;; '(100 . "AcDbScale")
;;; '(70 . 0)
;;; (cons 300 scale)
;;; (cons 140 (atoi scale))
;;; (cons 141 (atoi(substr scale (+ (vl-string-search ":" scale) 2))))
;;; '(290 . 0))))
;;; '(70 . 0)
;;; '(50 . 0.0)
;;; '(10 934.317 5247.03 0.0)
;;; '(11 0.0 0.0 0.0)
;((-1 . <图元名: 374dab80>)
;多行文字
'(0 . "ACDB_MTEXTOBJECTCONTEXTDATA_CLASS")
;'(5 . "4308")
'(102 . "{ACAD_REACTORS")
(cons 330 dicLv3)
'(102 . "}")
(cons 330 dicLv3)
'(100 . "AcDbObjectContextData")
'(70 . 4)
'(290 . 0)
'(100 . "AcDbAnnotScaleObjectContextData")
(cons 340 (entmakex (list '(0 . "SCALE")
'(102 . "{ACAD_REACTORS")
(cons 330 (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_SCALELIST"))))
'(102 . "}")
(cons 330 (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_SCALELIST"))))
'(100 . "AcDbScale")
'(70 . 0)
(cons 300 scale)
(cons 140 (atoi scale))
(cons 141 (atoi(substr scale (+ (vl-string-search ":" scale) 2))))
'(290 . 0))))
'(70 . 1)
'(10 1.0 0.0 0.0)
'(11 955.258 5258.21 0.0)
'(40 . 11.8314)
'(41 . 0.0)
'(42 . 0.396199)
'(43 . 0.140176)
'(71 . 2)
'(72 . 1)
'(44 . 11.8314)
'(45 . 0.685909)
'(73 . 0)
'(74 . 0)
'(46 . 0.0)
))
)
(entupd object)
)
)
(defun c:addt (/ blocks AcDbBlockTableRecord AcDbEntity)
(setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
; set annotative text style to be current
(setvar "textstyle" "Annotative")
(vlax-for AcDbBlockTableRecord blocks
(vlax-for AcDbEntity AcDbBlockTableRecord
(if(eq (vla-get-objectName AcDbEntity) "AcDbMText")
(progn
(setq text (vla-get-textString AcDbEntity))
(setq p0 (vla-get-insertionPoint AcDbEntity))
(setq hgt (vla-get-height AcDbEntity))
(setq obj (vla-addtext AcDbBlockTableRecord text p0 hgt)); add new text, annotative = yes
(vla-delete AcDbEntity) ; remove old text
); progn
); if
(vlax-release-object AcDbEntity)
); vlax-for
(vlax-release-object AcDbBlockTableRecord)
); vlax-for
(vlax-release-object blocks)
; globally apply annotation scales to annotative objects
(setvar "cannoscale" "1:2")
(setvar "cannoscale" "1:5")
(setvar "cannoscale" "1:10")
(princ)
)
虽然看不懂,但是顶一个 ;(addscale (car(entsel)) "1:2")
(defun AddScale (object scale / DefineNewDictHandle dicLv2 m1:1)
(defun DefineNewDictHandle(lst / leeter numbre handles retVal)
(foreach letter '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K")
(foreach number '(0 1 2 3 4 5 6 7 8 9)
(setq handles (cons (strcat "*" letter (itoa number)) handles))))
(setq handles (cdr(reverse handles)))
(while (member (setq retVal (car handles)) lst) (setq handles (cdr handles)))
retVal)
(setq dicLv2 (entget(cdr (assoc 350 (entget(cdr (assoc 360(entget(cdr (assoc 360 (entget object)))))))))))
(setq m1:1 (cdr(assoc 350 dicLv2)))
(setq dicLv2 (append dicLv2 (list (cons 3 (DefineNewDictHandle (apply 'append(mapcar '(lambda(x)(if(=(car x)3)(list(cdr x)))) dicLv2))))(cons 350 m1:1))))
(entmod dicLv2)
)
还是不成功
页:
[1]