2022年Teigha使用说明 2.pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年Teigha使用说明 2.pdf》由会员分享,可在线阅读,更多相关《2022年Teigha使用说明 2.pdf(9页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1、Teigha 中 DWG 数据库结构:经 常 用 到 的 有TextStyleTable 、 LayerTable 、 LinetypeTable 、 BlockTable及 其 对 应 的TextStyleTableRecord、LayerTableRecord、LinetypeTableRecord 、BlockTableRecord 及 Entity 。2、具体使用2.1 添加引用使用前应该添加TD_Mgd_3.03_9.dll或是其他版本类库,类库分为 64 位与 32 位,32 位类库在 64 位系统上运行效果可能不太好。3.02 版本及一下版本可能没有64 位的类库。命名空间有
2、:Teigha.DatabaseServices; Teigha.Geometry; Teigha.Colors; Teigha.Export_Import; Teigha.GraphicsInterface; Teigha.GraphicsSystem; Teigha.Runtime; 3.02 及以下版本命名空间应将Teigha 换为 DWGdirect 。名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 9 页 - - - - - - - - - 2.2 打开、新建、
3、保存数据库使用之前应加上这个:using ( Services ser = new Services ()/一个应用程序加上一个就行了,否则出错1、打开数据库(dwg 文件)using ( Database pDb = new Database(false , false )/不加参数会出错 pDb.ReadDwgFile(Application.StartupPath + TABMENU.dwg, FileOpenMode.OpenForReadAndWriteNoShare, false , ); 2、新建数据库using ( Database pDb = new Database()/加
4、参数出错3、保存(1)保存格式SaveType pSavetype = SaveType.Save12; /Save12 为.dwg Save13为dxf 默认保存为dwg,可以不用指定。(2)保存版本类型DwgVersion dwgver = DwgVersion.vAC18; /ACAD2010为 vAC24;ACAD2007 为 vAC21 ;ACAD2004 为vAC18 ;很重要,保存时要用,版本过高时低版本AutoCAD 不能打开。(3)保存pDb.SaveAs(filename, dwgver); pDb 为数据库( Database) ,filename 为 dwg 文件名,
5、dwgver 为版本。2.3 写数据2.3.1 添加文本样式ObjectId styleId = ObjectId .Null;using ( TextStyleTable pStyles = ( TextStyleTable)pDb.TextStyleTableId.GetObject(OpenMode .ForWrite) / 文本样式记录using ( TextStyleTableRecord pStyle = new TextStyleTableRecord() / 表对象(记录)添加到表之前必须命名/ isShapeFile flag must also be set (if tru
6、e) before adding the object名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 9 页 - - - - - - - - - / to the database. pStyle.Name = styleName;/ 必须设定 pStyle.IsShapeFile = isShapeFile;/ 添加(记录)到数据库之前必须设定(如果为 true )/ Add the object to the table.添加对象(记录)到表 styleId = pS
7、tyles.Add(pStyle); / 设置剩下的属性。(可以添加后设置也可以添加之前设置) pStyle.TextSize = textSize; pStyle.XScale = xScale; pStyle.PriorSize = priorSize; pStyle.ObliquingAngle = obliquing; pStyle.FileName = fileName; if (isShapeFile) pStyle.PriorSize = 22.45; if (! string.IsNullOrEmpty(ttFaceName) pStyle.Font = newFontDesc
8、riptor(ttFaceName, bold, italic, charset, pitchAndFamily); return styleId; 注: pDb 为 Database 2.3.2 添加线型using ( LinetypeTable pLinetypes = ( LinetypeTable )pDb.LinetypeTableId.GetObject(OpenMode .ForWrite) / 线表记录using ( LinetypeTableRecord pLinetype = new LinetypeTableRecord() pLinetype.Name = name;/
9、 必须命名ObjectId linetypeId = pLinetypes.Add(pLinetype);/ 添加记录return linetypeId; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 9 页 - - - - - - - - - 注:线型要有相应的线型文件,且不一定能够加成功,线型可以在使用之前手动加在dwg模板中,从其他文件向dwg 文件复制线型,可能不成功。2.3.3 添加块例:using ( BlockTable blockTable = (Blo
10、ckTable )pDb.BlockTableId.GetObject(OpenMode .ForWrite) ObjectId annoBlockId; using ( BlockTableRecord btr = new BlockTableRecord () btr.Name = AnnoBlock ; annoBlockId = blockTable.Add(btr); using ( Circle pCircle = new Circle () pCircle.SetDatabaseDefaults(pDb); btr.AppendEntity(pCircle); Point3d c
11、enter = new Point3d (0, 0, 0); pCircle.Center = center; pCircle.Radius = 0.5; 向块表中加入块之前,块一定要有名字。同时可以从其他文件中提取块,加入到目标数据库中例:using ( Database db = new Database( false , false ) if (! File .Exists(Application.StartupPath + BLOCKS + blockname + .dwg ) MessageBox .Show(没找到 CASS 块文件 ); returnObjectId .Null;
12、 db.ReadDwgFile(Application.StartupPath + BLOCKS+ blockname + .dwg , FileOpenMode.OpenForReadAndAllShare, false , ); using ( BlockTable pTable = ( BlockTable )db.BlockTableId.Open(OpenMode .ForRead) using ( BlockTable bt = ( BlockTable )pDb.BlockTableId.Open(OpenMode .ForWrite) 名师资料总结 - - -精品资料欢迎下载
13、- - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 9 页 - - - - - - - - - using ( BlockTableRecord btr = new BlockTableRecord () foreach ( ObjectId id in pTable) using ( BlockTableRecord pBlock = ( BlockTableRecord )id.Open( OpenMode .ForRead) foreach ( ObjectId entid in pBlock) using (
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年Teigha使用说明 2022 Teigha 使用说明
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内