明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2490|回复: 4

[求助]关于采用lisp修改标注样式的问题

[复制链接]
发表于 2009-4-15 22:13:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2009-4-16 21:49:55 编辑

本人想通过lisp程序修改标注样式的尺寸线、界线和文字的颜色为随层,代码如下:

    (setq dimen2 (tblobjname "dimstyle" “标注样式名称”)) ;使标注样式以对象符号存在
    (setq dimen2_data (entget dimen2))   ;取得对象列表
    (if (assoc 178 dimen2_data)    ;替换文字颜色
      (setq dimen2_data (subst (cons 178 256) (assoc 178 dimen2_data) dimen2_data))
      (setq dimen2_data (reverse (cons (cons 178 256) (reverse dimen2_data))))     
    )
    (if (assoc 176 dimen2_data)    ;替换尺寸线颜色
      (setq dimen2_data (subst (cons 176 256) (assoc 176 dimen2_data) dimen2_data))
      (setq dimen2_data (reverse (cons (cons 176 256) (reverse dimen2_data))))     
    )
    (if (assoc 177 dimen2_data)    ;替换尺寸界线颜色
      (setq dimen2_data (subst (cons 177 256) (assoc 177 dimen2_data) dimen2_data))
      (setq dimen2_data (reverse (cons (cons 177 256) (reverse dimen2_data))))    
    )
    (entmod dimen2_data)

现出现两个问题:1.标注样式内出现了替代样式;2.标注样式内设置的颜色已改对,但是图中以前用这个样式做的尺寸标注的颜色都没有变。

小弟刚学alisp不久,请高手帮忙改下。谢谢!

 楼主| 发表于 2009-4-16 19:56:00 | 显示全部楼层

版版帮忙解答一下吧,谢谢!

发表于 2012-12-31 16:27:37 | 显示全部楼层
Sub adAddDimStyle()
Dim a As AcadDimStyle
Dim b As AcadDimStyle
Dim c As AcadDimStyle
Dim d As AcadDimStyle
Dim e As AcadDimStyle
Dim f As AcadDimStyle

Set a = ThisDrawing.DimStyles.Add("1")
Set b = ThisDrawing.DimStyles.Add("DIMSTYLE_2")
Set c = ThisDrawing.DimStyles.Add("DIMSTYLE_3")
Set d = ThisDrawing.DimStyles.Add("DIMSTYLE_4")
Set e = ThisDrawing.DimStyles.Add("DIMSTYLE_5")
Set f = ThisDrawing.DimStyles.Add("DIMSTYLE_6")
ThisDrawing.ActiveDimStyle = a
With ThisDrawing
'The first group defines overall and linear scale factors
.SetVariable "Dimtxt", 96 'Overall Scale Factor. Determined by 12/Scale Factor.
.ActiveDimStyle.CopyFrom .ModelSpace

End With

ThisDrawing.ActiveDimStyle = a
With ThisDrawing
'The first group defines overall and linear scale factors
.SetVariable "Dimtxt", 22 'Overall Scale Factor. Determined by 12/Scale Factor.
Call b.CopyFrom(ThisDrawing.ModelSpace)
End With

ThisDrawing.ActiveDimStyle = a
With ThisDrawing
'The first group defines overall and linear scale factors
.SetVariable "Dimtxt", 44 'Overall Scale Factor. Determined by 12/Scale Factor.
Call c.CopyFrom(ThisDrawing.ModelSpace)
End With

ThisDrawing.ActiveDimStyle = d
With ThisDrawing
'The first group defines overall and linear scale factors
.SetVariable "Dimtxt", 99 'Overall Scale Factor. Determined by 12/Scale Factor.
Call d.CopyFrom(ThisDrawing.ModelSpace)
End With

ThisDrawing.ActiveDimStyle = e
With ThisDrawing
'The first group defines overall and linear scale factors
.SetVariable "Dimtxt", 122 'Overall Scale Factor. Determined by 12/Scale Factor.
Call e.CopyFrom(ThisDrawing.ModelSpace)
End With

ThisDrawing.ActiveDimStyle = f
With ThisDrawing
'The first group defines overall and linear scale factors
.SetVariable "Dimtxt", 1122 'Overall Scale Factor. Determined by 12/Scale Factor.
Call f.CopyFrom(ThisDrawing.ModelSpace)
End With
ThisDrawing.ActiveDimStyle = a
End Sub
发表于 2012-12-31 16:34:05 | 显示全部楼层
呵呵,想到了

command "-dimstyle" "要改动的样式名称" "dimtxt" 文字高度 "-dimstyle" "s" "要改动的样式名称" "Y"
发表于 2019-11-18 17:22:38 | 显示全部楼层
"dimclrd" "4" ;尺寸线、箭头和标注引线指定颜色。
"dimltype" "byblock" ;线型
"dimlwd" "-2" ;线宽
"dimdle" "0.6" ;超出标记,当使用小斜线代替箭头进行标注时
"dimdli" "0" ;基线间距,
"dimsd1" "0" ;隐藏尺寸线1,0显示,1隐藏
"dimsd2" "0" ;隐藏尺寸线2,0显示,1隐藏

;延伸线
"dimclre" "4" ;颜色
"dimltex1" "byblock" ;延伸线1的线型
"dimltex2" "byblock" ;延伸线2的线型
"dimlwe" "-2" ;线宽
"dimse1" "0" ;隐藏延伸线1,0显示,1隐藏
"dimse2" "0" ;隐藏延伸线2,0显示,1隐藏
"dimexe" "1" ;超出尺寸线的长度
"dimexo" "1" ;七点偏移量的长度
"dimfxlon" "0" ;固定长度的延伸线,关闭。

;符号和箭头
"dimblk1" "_ArchTick" ;第一个箭头样式,建筑标记
"dimblk2" "_ArchTick" ;第二个箭头样式,建筑标记
"dimldrblk" "_OPEN90" ;引线的箭头样式
"dimasz" "0.5" ;箭头大小
;圆心标记
"dimcen" "2.0" ;圆心标注方式为”标记“ 大小为2,0为无,直线为负数
;弧长符号
"dimarcsym" "1" ;三种样式分别为:0标注文字的前缀,1标注文字的上方,2无
;半径折弯标注
"dimjogang" "45" ;折弯角度
"dimlfac" "1" ;设置线性标注测量值的比例因子

;文字
"dimtxsty" "HZ" ;文字样式
"dimclrt" "3" ;文字颜色
"dimtfill" "0" ;不填充
"dimtxt" "2.5" ;文字高度
"dimtad" "1" ;垂直位置,0居中,1上方,2外部,3日本标准,4下方
"dimjust" "0" ;水平位置,0居中
"dimtxtdirection" "0" ;观察方向,0从左到右
"DIMGAP" "1" ;从尺寸线偏移
"dimtoh" "0" ;文字对齐样式,0与尺寸线对齐,1水平或ISO标准

;调整
"dimtix" "1" ;文字使用保持在尺寸界线之间
"dimsoxd" "0" ;若箭头。。。关闭
"dimtmove" "2" ;文字位置,尺寸线上方
"dimscale" (setq fmtval (rtos xcv 2 0)) ;全局比例
"dimupt" "0" ;手动放置位置位置,关闭
"dimtofl" "1" ;在延伸线之间绘制尺寸线,开启

;主单位
"dimdec" "0" ;精度
"dimdsep" "." ;小数分隔符
"dimrnd" "0.00000" ;舍入
"dimlfac" "1.00000" ;测量单位比例
"dimzin" "1" ;控制对主单位值的消零处理
;角度标注
"dimaunit" "0" ;角度标注的单位格式
"dimadec" "2" ;角度的精度
"dimazin" "2" ;角度后续消零

;换算单位
"dimalt" "0" ;关闭换算单位

;公差
"dimtol" "0" ;关闭换算单位
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-18 10:53 , Processed in 0.193597 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表