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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(VB.NET/C#) (http://www.dimcax.com/hust/forumdisplay.php?f=176)
-   -   【转帖】请问:如何在块中创建填充对象 (http://www.dimcax.com/hust/showthread.php?t=10087)

yang686526 2009-04-22 02:01 PM

【转帖】请问:如何在块中创建填充对象
 
请问:如何在块中创建填充对象
www.dimcax.com
请问:如何在块中创建填充对象
请问:如何在块中创建填充对象?
objectid blkobjid = new objectid();
database db = hostapplicationservices.workingdatabase;
using (transaction trans = db.transactionmanager.starttransaction())
{
blocktable bt = (blocktable)trans.getobject(db.blocktableid, openmode.forwrite);
if (bt.has("myblkname"))
{
blkobjid = bt["myblkname"];
}
else
{
point3d centerpoint = new point3d(0, 0, 0);
circle circle = new circle(centerpoint, vector3d.zaxis, 0.50);
hatch myhatch = new hatch();
myhatch.setdatabasedefaults();
myhatch.sethatchpattern(hatchpatterntype.predefined, "dots");
blocktablerecord newbtr = new blocktablerecord();
newbtr.name = "myblkname";
newbtr.origin = centerpoint;
blkobjid = bt.add(newbtr);
trans.addnewlycreateddbobject(newbtr, true);
objectid loopid = newbtr.appendentity(circle);
newbtr.appendentity(myhatch);
trans.addnewlycreateddbobject(circle, true);
trans.addnewlycreateddbobject(myhatch, true);
objectidcollection ids = new objectidcollection();
ids.add(loopid);
myhatch.patternangle = 0.0;
myhatch.patternscale = 0.1;
myhatch.associative = true;
myhatch.appendloop(hatchlooptypes.default, ids);
myhatch.evaluatehatch(true);

}
trans.commit();
}
return blkobjid;
不过有个问题:myhatch.patternscale = 0.1好像不起作用,设置后的填充图案没有按比例发生相应的变化
point3d centerpoint = new point3d(0, 0, 0);
circle circle = new circle(centerpoint, vector3d.zaxis, 0.5);
hatch myhatch = new hatch();
blocktablerecord newbtr = new blocktablerecord();
newbtr.name = "cnj";
newbtr.origin = centerpoint;
blkobjid = bt.add(newbtr);
trans.addnewlycreateddbobject(newbtr, true);
objectid loopid = newbtr.appendentity(circle);
newbtr.appendentity(myhatch);
trans.addnewlycreateddbobject(circle, true);
trans.addnewlycreateddbobject(myhatch, true);
objectidcollection ids = new objectidcollection();
ids.add(loopid);
myhatch.patternangle = 0.0;
myhatch.patternscale = 0.1;
myhatch.setdatabasedefaults();
myhatch.sethatchpattern(hatchpatterntype.predefined, "dots");
myhatch.associative = true;
myhatch.appendloop(hatchlooptypes.default, ids);
myhatch.evaluatehatch(true);
在木头大哥的帮助下解决的,在此以表感!


所有的时间均为北京时间。 现在的时间是 07:08 PM.