请问:如何在块中创建填充对象
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);
在木头大哥的帮助下解决的,在此以表感!