几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(VB.NET/C#)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-20, 10:45 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】c#生成关联填充的方法

c#生成关联填充的方法
www.dimcax.com
c#生成关联填充的方法
, ,
c#要生成有关联性的填充,以前推荐的是调用arx的方法,但是非常麻烦。
本论坛的超级版主ahlzl经过不懈的努力,终于找到了纯粹的用c#来实现关联填充的方法,详见下面的代码。
using system;
using autodesk.autocad.databaseservices;
using autodesk.autocad.geometry;
using autodesk.autocad.runtime;
namespace associativehatch
{
public class commands
{
[commandmethod("test")]
public void associativehatch()
{
database db = hostapplicationservices.workingdatabase;
line lineent1 = new line(new point3d(0, 0, 0), new point3d(1000, 0, 0));
line lineent2 = new line(new point3d(1000, 0, 0), new point3d(800, 600, 0));
line lineent3 = new line(new point3d(800, 600, 0), new point3d(0, 0, 0));
circle circleent = new circle(new point3d(500, loops = new objectidcollection[2];
loops.setvalue(loops1, 0);
loops.setvalue(loops2, 1);
hatch hatchent;
objectid hatentid = addhatch(out hatchent, 0, "angle", math.pi / 3, 10);
using (transaction tr = db.transactionmanager.starttransaction())
{
hatchent = (hatch)tr.getobject(hatentid, openmode.forwrite);
hatchent.associative = true;
for (int i = 0; i < loops.length; i++)
{
hatchent.appendloop(hatchlooptypes.default, loops);
}
tr.commit();
}
}
private objectid addhatch(out hatch hatchent, hatchpatterntype pattype,
string patname, double patternangle, double patternscale)
{
hatch ent = new hatch();
ent.hatchobjecttype = hatchobjecttype.hatchobject;
database db = hostapplicationservices.workingdatabase;
using (transaction trans = db.transactionmanager.starttransaction())
{
blocktable bt = (blocktable)trans.getobject
(db.blocktableid, openmode.forread);
blocktablerecord btr = (blocktablerecord)trans.getobject
(bt[blocktablerecord.modelspace], openmode.forwrite);
objectid entid = btr.appendentity(ent);
trans.addnewlycreateddbobject(ent, true);
ent.setdatabasedefaults();
ent.patternangle = patternangle;
ent.patternscale = patternscale;
ent.sethatchpattern(pattype, patname);
hatchent = ent;
trans.commit();
return entid;
}
}
private objectid appendentity(entity ent)
{
database db = hostapplicationservices.workingdatabase;
objectid entid;
using (transaction trans = db.transactionmanager.starttransaction())
{
blocktable bt = (blocktable)trans.getobject(db.blocktableid,
openmode.forread);
blocktablerecord btr = (blocktablerecord)trans.getobject
(bt[blocktablerecord.modelspace], openmode.forwrite);
entid = btr.appendentity(ent);
trans.addnewlycreateddbobject(ent, true);
trans.commit();
}
return entid;
}
}
}
复制代码
具体的原因和注意事项,还请卢老大来补充。
好东西!牛
vb c# vlisp autocad gis
我用

估计
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 09:48 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多