- 积分
- 1753
- 明经币
- 个
- 注册时间
- 2011-11-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
如果你添加了一个字体样式,那么查遍它所有的属性,并没有发现其对宽度因子的设置,那么只有调用VBA方法喽,下面是示例代码- 引用:net接口
- C:\Program Files\Autodesk\AutoCAD 2012 - Simplified Chinese\acdbmgd.dll
- C:\Program Files\Autodesk\AutoCAD 2012 - Simplified Chinese\acmgd.dll
- com接口
- C:\Program Files\Common Files\Autodesk Shared\axdb18enu.tlb
- C:\Program Files\Common Files\Autodesk Shared\acax18enu.tlb
- 配置:.netframework 4.0 CAD2012 VS2010
- Imports Autodesk.AutoCAD.Runtime
- Imports Autodesk.AutoCAD.ApplicationServices
- Imports Autodesk.AutoCAD.DatabaseServices
- Imports Autodesk.AutoCAD.EditorInput
- Imports Autodesk.AutoCAD.Geometry
- Imports Autodesk.AutoCAD.Interop.Common
- Imports Autodesk.AutoCAD.Interop
- Public Class class1
- <CommandMethod("aaaa")> _
- Public Sub UpdateTextFont()
- Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
- Dim acCurDb As Database = acDoc.Database
- Dim Mztilist As New List(Of String)
- Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
- '以net的访问方式判断是否存在已知字体样式
- Dim Mtexttable As TextStyleTable = acTrans.GetObject(acCurDb.TextStyleTableId, OpenMode.ForRead)
- For Each Id As ObjectId In Mtexttable
- Dim TblRec As TextStyleTableRecord = acTrans.GetObject(Id, OpenMode.ForRead)
- Mztilist.Add(TblRec.Name)
- Next
- '以com对象的方法添加字体样式
- If Not Mztilist.Contains("JHZX") Then
- ' Dim Mjhst As New TextStyleTableRecord
- 'Mjhst.Name = "JHZXaa"
- 'Mjhst.BigFontFileName = "hztxt.shx"
- 'Mjhst.FileName = "ros.shx"
- Dim thisdrawing As AcadDocument = CType(acDoc.AcadDocument, AcadDocument)
- Dim Mcomtext As AcadTextStyle = thisdrawing.TextStyles.Add("JHZXaa")
- Mcomtext.BigFontFile = "hztxt.shx"
- Mcomtext.fontFile = "ros.shx"
- Mcomtext.Width = 0.75
- thisdrawing.ActiveTextStyle = Mcomtext
- thisdrawing.Regen(AcRegenType.acActiveViewport)
- 'Mtexttable.UpgradeOpen()
- 'Mtexttable.Add(Mjhst)
- 'acTrans.AddNewlyCreatedDBObject(Mjhst, True)
- End If
- 'acCurDb.Textstyle = Mtexttable("JHZX")
- 'Application.SetSystemVariable("TEXTSTYLE", "JHZX")
- ' HostApplicationServices.Current.FindFile("bigfont.shx", acCurDb, FindFileHint.FontFile)
- acTrans.Commit()
- End Using
- End Sub
- end class
|
|