entmake 插入带属性文字块
本帖最后由 冒个烟圈 于 2018-7-20 16:59 编辑ENTMAKE ATTRIB 时属性文字插入点在WCS原点,有没有办法让文字插入点跟随用户鼠标在一个点?
大神们教教我,谢谢!!!
能达到下图右边的效果
以下附上代码
(defun c:NN()
(setvar "cmdecho" 0)
(command ".UNDO" "BE")
(setq BNO (getint "\n输入整数编号"))
(if (not (tblsearch "layer" "dim" ))
(progn (command "layer" "new" "dim" "s" "dim" "C" 3 "" "L" "Continuous" "" "LW" 0.15 "" "")))
(setq scl (getvar "dimscale"))
(entmake (list '(0 . "block")'(2 . "BVer")'(70 . 2)'(8 . "dim")(cons 10 '(0.0 0.0 0.0))))
(entmake (list '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(8 . "dim")
'(90 . 6)
'(70 . 1)
'(10 -0.259808 3.3)
'(42 . 0.0)
'(10 -2.98779 -1.425)
'(42 . 0.57735)
'(10 -2.72798 -1.875)
'(42 . 0.0)
'(10 2.72798 -1.875)
'(42 . 0.57735)
'(10 2.98779 -1.425)
'(42 . 0.0)
'(10 0.259808 3.3)
'(42 . 0.57735)))
(entmake '((0 . "ENDBLK")))
(while
(setq y1 (getpoint "\n>>>指定放置点:"))
(entmake (list'(0 . "INSERT")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockReference")
'(66 . 1);;;属性跟随标志,1跟随,0不跟随
(cons 2 "BVer")
(cons 8 "DIM")
(cons 10 y1)
(cons 41 scl)
(cons 42 scl)
(cons 43 scl)))
(entmake (list'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
'(62 . 4)
(cons 8 "DIM")
(cons 10 y1)
(cons 40 2)
(cons 1 (itoa BNO))
(cons 72 4)
'(100 . "AcDbAttribute")
(cons 2 "Ver")
(cons 70 0)))
(entmake '((0 . "SEQEND")))
)
(command ".UNDO" "E")
(princ)
)
USER2128 发表于 2018-7-21 09:30
其实只要在(list'(0 . "ATTRIB") ... (cons 10 y1) 之后加入一行:
(cons 11 y1)
就行了
(defun c:NN()
(setvar "cmdecho" 0)
(command ".UNDO" "BE")
(setq BNO (getint "\n输入整数编号"))
(if (not (tblsearch "layer" "dim" ))
(progn (command "layer" "new" "dim" "s" "dim" "C" 3 "" "L" "Continuous" "" "LW" 0.15 "" "")))
(setq scl (getvar "dimscale"))
(entmake (list '(0 . "block")'(2 . "BVer")'(70 . 2)'(8 . "dim")(cons 10 '(0.0 0.0 0.0))))
(entmake (list '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(8 . "dim")
'(90 . 6)
'(70 . 1)
'(10 -0.259808 3.3)
'(42 . 0.0)
'(10 -2.98779 -1.425)
'(42 . 0.57735)
'(10 -2.72798 -1.875)
'(42 . 0.0)
'(10 2.72798 -1.875)
'(42 . 0.57735)
'(10 2.98779 -1.425)
'(42 . 0.0)
'(10 0.259808 3.3)
'(42 . 0.57735)))
(entmake '((0 . "ENDBLK")))
(while
(setq y1 (getpoint "\n>>>指定放置点:"))
(entmake (list'(0 . "INSERT")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockReference")
'(66 . 1);;;属性跟随标志,1跟随,0不跟随
(cons 2 "BVer")
(cons 8 "DIM")
(cons 10 y1)
(cons 41 scl)
(cons 42 scl)
(cons 43 scl)))
(entmake (list'(0 . "ATTRIB")
'(100 . "AcDbEntity")
'(100 . "AcDbText")
'(62 . 4)
(cons 8 "DIM")
(cons 10 y1)
(cons 11 y1)
(cons 40 2)
(cons 1 (itoa BNO))
(cons 72 4)
'(100 . "AcDbAttribute")
(cons 2 "Ver")
(cons 70 0)))
(entmake '((0 . "SEQEND")))
)
(command ".UNDO" "E")
(princ)
)
测试通过 (cadr (grread t 1)) ;取鼠标所在位置点.
USER2128 发表于 2018-7-21 08:12
(cadr (grread t 1)) ;取鼠标所在位置点.
(cons 10 (cadr (grread t 1)))这样吗?
具体加到哪处,能否说得详细些,谢谢 其实只要在(list'(0 . "ATTRIB") ... (cons 10 y1) 之后加入一行:
(cons 11 y1)
就行了 学习了 只会插入块 属性块还真不会 lifuq1979 发表于 2018-7-21 10:40
(defun c:NN()
(setvar "cmdecho" 0)
(command ".UNDO" "BE")
多谢指点。。谢谢! 本帖最后由 冒个烟圈 于 2018-7-21 14:38 编辑
USER2128 发表于 2018-7-21 09:30
其实只要在(list'(0 . "ATTRIB") ... (cons 10 y1) 之后加入一行:
(cons 11 y1)
就行了
谢谢指点,,谢谢!!!
问个题外问题:提问的贴子怎么设置成已解决状态
组码10和11都要有才得
页:
[1]