- 积分
- 289
- 明经币
- 个
- 注册时间
- 2018-4-8
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2018-4-15 17:20:28
|
显示全部楼层
本帖最后由 dogingate 于 2018-4-15 23:23 编辑
对这个组码表对了半天,layer和style的还好,不多,dimstyle的太多了,又不按照字母顺序,一个个找的,累啊
以下命令就是创建layer、style和dimstyle的,可以新建也可以对已存在的进行修改
代码还是有点长,不知道还可以优化不?
(defun c:bzh()
;;;创建或修改图层
;;;(sub_chk_layer lname lcolor llt llw lp)
(sub_chk_layer "#000" 8 "Continuous" -1 1);;;原始层,8灰
(sub_chk_layer "#001" 3 "Continuous" -1 1);;;标注文字,3绿,2.5高
(sub_chk_layer "#002" 4 "Continuous" -1 1);;;说明文字,4青,3.0高
(sub_chk_layer "#003" 7 "Continuous" -1 1);;;结构,7白
(sub_chk_layer "#004" 8 "Continuous" -1 0);;;辅助层,8灰,不打印
;;;创建文字样式
;;;(sub_chk_style sname shxname bigfontname)
(sub_chk_style "#wolf_romand" "ecidi_romand.shx" "ecidi_hzfs.shx")
(sub_chk_style "#wolf_romans" "ecidi_romans.shx" "ecidi_hzfs.shx")
;;;创建标注样式
;;;sub_chk_dimstyle(dname dscale dtxtheight ddecnumber sname)
(sub_chk_dimstyle "#wolf_1-1_cm" 1.0 2.5 1 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-10_cm" 10.0 2.5 1 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-20_cm" 20.0 2.5 1 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-25_cm" 25.0 2.5 1 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-50_cm" 50.0 2.5 1 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-100_cm" 100.0 2.5 1 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-1" 1.0 2.5 0 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-10" 10.0 2.5 0 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-20" 20.0 2.5 0 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-25" 25.0 2.5 0 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-50" 50.0 2.5 0 "#wolf_romand")
(sub_chk_dimstyle "#wolf_1-100" 100.0 2.5 0 "#wolf_romand")
(princ)
)
(defun sub_chk_layer(lname lcolor llt llw lp)
(if (null (tblsearch "layer" lname))
(sub_layer_create lname lcolor llt llw lp)
(sub_layer_modify lname lcolor llt llw lp)
)
)
(defun sub_layer_create(lname lcolor llt llw lp)
(entmake (list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
'(70 . 0)
(cons 2 lname);层名
(cons 62 lcolor);颜色
(cons 6 llt);线型
(cons 370 llw);线宽,-1=Default
(cons 290 lp);0不打印,1打印)
))
(prompt (strcat "\n图层" lname "创建完毕"))
)
(defun sub_layer_modify(lname lcolor llt llw lp)
(setq ename (tblobjname "layer" lname))
(setq elist (entget ename))
(setq elist (elist_subst 62 lcolor elist))
(setq elist (elist_subst 6 llt elist))
(setq elist (elist_subst 370 llw elist))
(setq elist (elist_subst 290 lp elist))
(entmod elist)
(prompt (strcat "\n图层" lname "修改完毕"))
)
(defun sub_chk_style(sname shxname bigfontname)
(if (null (tblsearch "style" sname))
(sub_style_create sname shxname bigfontname)
(sub_style_modify sname shxname bigfontname)
)
)
(defun sub_style_create(sname shxname bigfontname)
(entmake (list
'(0 . "STYLE")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbTextStyleTableRecord")
'(70 . 0)
(cons 2 sname);文字样式名称
(cons 40 0);固定文字高度,为0时表示高度不固定
(cons 41 0.80);宽度系数
(cons 50 0.0);倾斜角度
;(cons 71 0);文字产生标志
;(cons 42 0.0);最后使用的高度
(cons 3 shxname);shx字体
(cons 4 bigfontname);大字体
)
)
(prompt (strcat "\n文字样式" sname "创建完毕"))
)
(defun sub_style_modify(sname shxname bigfontname)
(setq ename (tblobjname "style" sname))
(setq elist (entget ename))
(setq elist (elist_subst 40 0 elist))
(setq elist (elist_subst 41 0.8 elist))
(setq elist (elist_subst 50 0 elist))
(setq elist (elist_subst 3 shxname elist))
(setq elist (elist_subst 4 bigfontname elist))
(entmod elist)
(prompt (strcat "\n文字样式" sname "修改完毕"))
)
(defun elist_subst(dxfcode dxfcodevalue elist)
(subst (cons dxfcode dxfcodevalue) (assoc dxfcode elist) elist)
)
(defun sub_chk_dimstyle(dname dscale dtxtheight ddecnumber sname)
(if (null (tblsearch "dimstyle" dname))
(sub_dimstyle_create dname dscale dtxtheight ddecnumber sname)
(sub_dimstyle_modify dname dscale dtxtheight ddecnumber sname)
)
)
(defun sub_dimstyle_create(dname dscale dtxtheight ddecnumber sname)
(entmake (list
'(0 . "dimstyle")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbDimStyleTableRecord")
'(70 . 0)
(cons 2 dname);标注样式名
(cons 40 dscale);dimscale,全局标注比例因子
(cons 140 dtxtheight);dimtxt,标注文字高度
(cons 271 ddecnumber);dimdec,主单位标注的公差值的小数位数
(cons 340 (tblobjname "style" sname))
(cons 41 2.0);dimasz,直线和箭头-标注箭头尺寸
(cons 42 2.5);dimexo,尺寸界线偏移
(cons 43 7.0);dimdli,尺寸界线增量
(cons 44 1.5);dimexe,尺寸界线延伸
(cons 49 1.5)
(cons 73 0);dimtih,非零时将文字水平放在内侧
(cons 74 0);dimtoh,非零时将文字水平放在外侧
(cons 77 1);dimtad,非零时文字在尺寸线上方
(cons 78 8);dimzin,控制是否对主单位值做消零处理:0(1)=消除(包含)零英尺和零英寸
(cons 141 0.0);dimcen,中心标记/中心线的大小
(cons 147 0.68);dimgap,尺寸线间距
(cons 171 4);dimaltd,换算单位小数位
(cons 172 1);dimtofl,如果文字放在尺寸界线外侧,非零时则强制在尺寸界线之间画直线
(cons 174 1);dimtix,非零时将文字强制放在尺寸界线的内侧
(cons 176 256);dimclrd,尺寸线颜色,0=byblock,256=bylayer
(cons 177 256);dimclre,尺寸界线颜色,0=byblock,256=bylayer
(cons 178 256);dimclrt,标注文字颜色,0=byblock,256=bylayer
(cons 272 1);dimtdec,显示公差值的小数位数
(cons 274 4);dimalttd,换算单位标注的公差值的小数位数
(cons 279 1);dimtmove,标注文字移动规则:0-尺寸线和标注文字一起移动,1=移动标注文字时添加引线,2=允许标注文字自由移动而不添加引线
(cons 290 1)
))
(prompt (strcat "\n标注样式" dname "创建完毕"))
)
(defun sub_dimstyle_modify(dname dscale dtxtheight ddecnumber sname)
(setq ename (tblobjname "dimstyle" dname))
(setq elist (entget ename))
(setq elist (elist_subst 40 dscale elist))
(setq elist (elist_subst 140 dtxtheight elist))
(setq elist (elist_subst 271 ddecnumber elist))
(setq elist (elist_subst 340 (tblobjname "style" sname) elist))
(setq elist (elist_subst 41 2.0 elist))
(setq elist (elist_subst 42 2.5 elist))
(setq elist (elist_subst 43 7.0 elist))
(setq elist (elist_subst 44 1.5 elist))
(setq elist (elist_subst 49 1.5 elist))
(setq elist (elist_subst 73 0 elist))
(setq elist (elist_subst 74 0 elist))
(setq elist (elist_subst 77 1 elist))
(setq elist (elist_subst 78 8 elist))
(setq elist (elist_subst 141 0.0 elist))
(setq elist (elist_subst 147 0.68 elist))
(setq elist (elist_subst 171 4 elist))
(setq elist (elist_subst 172 1 elist))
(setq elist (elist_subst 174 1 elist))
(setq elist (elist_subst 176 256 elist))
(setq elist (elist_subst 177 256 elist))
(setq elist (elist_subst 178 256 elist))
(setq elist (elist_subst 272 1 elist))
(setq elist (elist_subst 274 4 elist))
(setq elist (elist_subst 279 1 elist))
(setq elist (elist_subst 290 1 elist))
(entmod elist)
(prompt (strcat "\n标注样式" dname "修改完毕"))
)
|
|