明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2346|回复: 0

与大家探讨如何用c#标住尺寸

[复制链接]
发表于 2005-6-17 14:51:00 | 显示全部楼层 |阅读模式
感谢斑竹提供c#开发AutoCAD的方法,本人刚开始学习,现在兴趣很大,就学习中的一些问题和大家交流一下,不正确处请指教. 认真看了斑竹的学习资料后决定用AlignedDimension和LineAngularDimension2画个尺寸,开始用如下方法尝试: Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction();
AlignedDimension dd1=new AlignedDimension();
dd1.XLine1Point=new Point3d(10,10,0);
dd1.XLine2Point=new Point3d(200,200,0);
dd1.DimLinePoint=new Point3d(100,100,0);
dd1.Oblique=120.00;
LineAngularDimension2 ll2=new LineAngularDimension2();
ll2.XLine1Start=new Point3d(10,10,0);
ll2.XLine1End=new Point3d(10,15,0);
ll2.XLine2Start=new Point3d(10,10,0);
ll2.XLine2End=new Point3d(20,15,0);
trans.AddNewlyCreatedDBObject(dd1,true);
trans.AddNewlyCreatedDBObject(ll2,true);
trans.Commit();
trans.Dispose(); 可是调试错误,后来通过学习发现,在实体构造上出现问题(不明白line,circle如何就可以),需要重新构建,做如下修改就可: 构件实体函数: public static ObjectId AddEntity(Entity ent)
{Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction();
Database Db1=HostApplicationServices.WorkingDatabase; try
{
BlockTable bt =
(BlockTable)trans.GetObject(Db.BlockTableId, OpenMode.ForWrite, false);
BlockTableRecord btr =
BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace],
OpenMode.ForWrite, false);
btr.AppendEntity(ent);
trans.AddNewlyCreatedDBObject(ent, true);
trans.Commit();
return ent.ObjectId;
}

}
catch (System.Exception e)
{
throw e;
}
} 将原计算方法修改为: AlignedDimension dd1=new AlignedDimension();
dd1.XLine1Point=new Point3d(10,10,0);
dd1.XLine2Point=new Point3d(200,200,0);
dd1.DimLinePoint=new Point3d(100,100,0);
dd1.Oblique=120.00;
LineAngularDimension2 ll2=new LineAngularDimension2();
ll2.XLine1Start=new Point3d(10,10,0);
ll2.XLine1End=new Point3d(10,15,0);
ll2.XLine2Start=new Point3d(10,10,0);
ll2.XLine2End=new Point3d(20,15,0);
ObjectId id = AddEntity(dd1);
ObjectId id1 = AddEntity(ll2); 就可以成功了. 真不明白autodesk公司为什么设计这么复杂,希望大家一起探讨.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 06:36 , Processed in 0.163881 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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