本帖最后由 cq4920 于 2022-9-21 22:03 编辑
直接创建 属性快 总是不成功,没办法 绕个弯路吧
速度还可以,就是插入的一瞬间有明显的卡顿,优化后的效果还挺好的
简单了解了一下字典,还真是挺好用的,带了记忆功能
- (defun c:bh(/ ent date name time)
- (setvar "OrthoMode" 0);;;关闭正交
- (asdf2);;;创建文字样式“新宋体”,没有就DXF组码7的值删改一下!
- (setq name (vlax-ldata-get "字典" "name1")) ;;读取字典数据
- (if (= name nil)
- (progn ;;则设置
- (setq name (substr (rtos (getvar "cdate") 2 6) 10)) ;;首次运行,设默认
- (vlax-ldata-put "字典" "name1" name)
- )
- )
- (setq newname (getstring (strcat "\n请输入编号<" name ">:")))
- (if (= newname "") (setq newname name)) ;;如果用户直接回车,则使用默认
- (setq name newname)
- (vlax-ldata-put "字典" "name1" newname)
-
- (if (= (tblsearch "Block" name) nil)
- (progn
- (setq ent (entlast))
- (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 6) '(70 . 1)
- '(10 2.5 5.0)
- '(10 25.5 5.0)
- '(10 28.0 2.5)
- '(10 25.5 0.0)
- '(10 2.5 0.0)
- '(10 0.0 2.5)
- '(8 . "W-索引符号")
- '(62 . 211)
- ))
- (entmake (list '(0 . "LINE") '(100 . "AcDbEntity") '(8 . "W-索引符号") '(62 . 211) '(100 . "AcDbLine") '(10 12.5 5.0 0.0) '(11 12.5 0.0 0.0)))
- (entmake (list '(0 . "ATTDEF")'(100 . "AcDbEntity")'(8 . "W-索引符号")'(62 . 2)'(100 . "AcDbText")
- '(10 2.40891 0.790438 0.0)'(40 . 3.375)(CONS 1 NAME)'(50 . 0.0)'(41 . 0.831213)'(51 . 0.0)'(7 . "新宋体")'(71 . 0)'(72 . 5)'(11 12.4392 0.790438 0.0)'(210 0.0 0.0 1.0)'(100 . "AcDbAttributeDefinition")'(280 . 0)'(3 . "")'(2 . "编号")'(70 . 8)'(73 . 0)'(74 . 0)'(280 . 0)))
- (entmake '((0 . "ATTDEF")(100 . "AcDbEntity")(8 . "W-索引符号")(62 . 2)(100 . "AcDbText")
- (10 12.5 0.789728 0.0)(40 . 3.375)(1 . "乳胶漆")(50 . 0.0)(41 . 0.831213)(51 . 0.0)(7 . "新宋体")(71 . 0)(72 . 5)(11 25.5 0.789728 0.0)(210 0.0 0.0 1.0)(100 . "AcDbAttributeDefinition")(280 . 0)(3 . "")(2 . "名称")(70 . 8)(73 . 0)(74 . 0)(280 . 0)))
-
- (COMMAND "-block" name "0,2.5" (last_ent ent) "")
- (command "ATTREQ" "0")
- (command "INSERT" name '(0 0) "1" "1" "0")
- (COMMAND "MOVE" (entlast) "" '(0 0) pause)
- )
- (progn
- (command "ATTREQ" "0")
- (command "INSERT" name '(0 0) "1" "1" "0")
- (COMMAND "MOVE" (entlast) "" '(0 0) pause) )
-
- )
- )
-
- ;;40最后生产出的图元
- (defun last_ent (en / ss)
- (if en
- (progn
- (setq ss (ssadd))
- (while (setq en (entnext en))
- (if (not (member (cdr (assoc 0 (entget en)))
- '("ATTRIB" "VERTEX" "SEQEND")
- )
- )
- (ssadd en ss)
- );if
- );while
- (if (zerop (sslength ss)) (setq ss nil))
- ss
- );progn
- (ssget "_x")
- );if
- )
-
|