如何将新增加的textstyletablerecord设为当前
www.dimcax.com
如何将新增加的textstyletablerecord设为当前
如何将新增加的textstyletablerecord设为当前,在增加字体类型时遇到一个费解问题,就是我增加两种字形的textstyletablerecord,一种是将cad默认的字型standard改为“仿宋“体,另外增加一种字体样式"ksj",字型为ksj.ttf,结果是我先定义哪一个字型,两种字体样式都是这一种字型,试了多少遍了,各种招都用了,还是不行。我想是不是在修改自行是要改为当前字体样式,但找不到设置为当前字体样式的方法
你试一下autodesk.autocad.databaseservices.database.textstyle属性
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
c#和vbnet用法差不多,autodesk.autocad.databaseservices.database.textstyle是得到,只读属性,而不能设置.c#的代码也行
textstyle属性是可写的,textstyletableid属性是只读的。
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
好像不起作用,还是原来那样,不能改变字体
设置当前字体: hostapplicationservices.workingdatabase.celtype = str.objectid str是你的textstyletablerecord。
celtype -----gets or sets the object id of the linetype specified by the current celtype value of the database. 是定义线型的,不是定义字型的。
实在不行的话,请用一下setsystemvariable函数设置“textstyle”系统变量。
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
database.textstyle = tools.addtextstyle("断面"); public static objectid addtextstyle(string stylename) { objectid id; database db = tools.database; dbtransman tm = tools.transactionmanager; transaction ta = tm.starttransaction(); textstyletable textstyletable = (textstyletable)tm.getobject(db.textstyletableid, openmode.forread, false); if (textstyletable.has(stylename)) { id = textstyletable[stylename]; } else { textstyletable.upgradeopen(); textstyletablerecord textstylerec = new textstyletablerecord(); textstylerec.name = stylename; textstylerec.xscale = 0.8; textstylerec.filename = "romans.shx"; textstylerec.bigfontfilename = "htj_s.shx"; id = textstyletable.add(textstylerec); tm.addnewlycreateddbobject(textstylerec, true); } ta.commit(); ta.dispose(); return id; }
楼上的只是建立了一个字体样式,没有实际设置为当前图形的默认字体样式
1