cad二次开发(块表的创建) (1)(2)

2019-03-22 11:29

代码:

public partial class BlockLookingForm : Form {

public Document docu; Database DB;

BlockTable blockTable;

public BlockLookingForm(Document docu, Database DB, BlockTable blockTable) {

InitializeComponent(); this.docu = docu; this.DB = DB;

this.blockTable = blockTable; }

private void btnLooking_Click(object sender, EventArgs e) {Database database = docu.Database; try

{using (Transaction trans =

database.TransactionManager.StartTransaction()) {

blockTable = trans.GetObject(database.BlockTableId, OpenMode.ForRead) as BlockTable;

BlockTableRecord blockTableRecord =

trans.GetObject(blockTable[txtBlockName.Text.Trim()], OpenMode.ForRead) as BlockTableRecord;

int Count = 0;

foreach (ObjectId id in blockTableRecord)

{Entity entity = trans.GetObject(id, OpenMode.ForRead, false) as Entity;

if (entity is AttributeDefinition) {

txtAttri.Text = \有\; }

Count++; }

txtEntity.Text = Count.ToString();

Bitmap bitmap = blockTableRecord.PreviewIcon; if (bitmap != null) {

System.Drawing.Image image = System.Drawing.Image.FromHbitmap(bitmap.GetHbitmap()); pictureBox1.Image = image; pictureBox1.Refresh(); }

trans.Commit(); } }

catch (Exception ex) {

MessageBox.Show(\有错误\+ex.Message); }

5.3、在创建块表命令方法中添加下面的代码:

CreateBlockIcon createBlockIcon = new CreateBlockIcon(blockName);

5.4、然后在命令方法中显示块表查看器

四、实验总结

通过实验,使我更加懂得了自己动手的重要性,在课堂上虽然听懂了老师讲的内容,但在实际编程过程中还是会出现许多的问题,只有通过自己亲身去实践,这样才是真正的学到了属于自己的东西。


cad二次开发(块表的创建) (1)(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:新手开服装加盟店在进货中要注意哪些问题

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: