我用的vb2008和cad2007,我写了一下代码,但是会出现“样式代替”,请问这是怎么回事?
-
- <CommandMethod("netDimStyle")> Public Sub CreateDimStyle()
- Dim db As Database = HostApplicationServices.WorkingDatabase
- Using trans As Transaction = db.TransactionManager.StartTransaction
- ' 得到标注样式表
- Dim dt As DimStyleTable = trans.GetObject(db.DimStyleTableId, OpenMode.ForWrite)
- Dim StyleName As String = "MyDim"
- ' 如果名为"MyDim"的样式不存在,则新建一个文字样式.
- If dt.Has(StyleName) = False Then
- ' 新建一个标注样式表记录.
- Dim dtr As New DimStyleTableRecord()
- ' 设置标注样式名.
- dtr.Name = StyleName
- ' 箭头大小
- dtr.Dimasz = 3
- '' 尺寸线间距
- dtr.Dimdli = 3.75
- '' 小数分隔符
- 'dtr.Dimdsep = ","
- '' 尺寸界线超出量
- 'dtr.Dimexe = 1.25
- '' 尺寸界线偏移
- dtr.Dimexo = 0.625
- '' 文字偏移
- 'dtr.Dimgap = 0.625
- '' 文字位置垂直
- dtr.Dimtad = 1
- '' 文字在内对齐
- dtr.Dimtih = False
- ' 文字高度
- dtr.Dimtxt = 3
- Dim DimstyleId As ObjectId = dt.Add(dtr)
- ' 把标注样式表记录添加到事务处理中.
- trans.AddNewlyCreatedDBObject(dtr, True)
- ' 将标注样式"MyDim"设置为当前标注样式
- db.Dimstyle = DimstyleId
- trans.Commit()
- End If
- End Using
- End Sub
|