.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to user Iterator to check Attributes inside BlockDefinition in C#?

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
209 Views, 3 Replies

How to user Iterator to check Attributes inside BlockDefinition in C#?

Hi,

I'm trying to insert a block with attributes into drawing file model spacel.
I can only see the block, and can't get the attributes inserted. I think I
need to loop check the block definition, find attribute definitions in it,
and insert these attributes.

Following is the code to do insert block:
Autodesk.AutoCAD.DatabaseServices.BlockReference blkRef = new
BlockReference(insPnt, blockID);



using (Transaction myT = tm.StartTransaction())

{

BlockTable bt =
(BlockTable)tm.GetObject(currentdb.BlockTableId,OpenMode.ForRead, false);

BlockTableRecord btr =
(BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite,false);

btr.AppendEntity(blkRef);

tm.AddNewlyCreatedDBObject(blkRef, true);

myT.Commit();

}



Thank you for any helps.

Zhongwei Xia
3 REPLIES 3
Message 2 of 4
totu
in reply to: Anonymous

My QQ is:29873620 ,join me and talk ,ok?
now try to develop with c# and 2006
Message 3 of 4
Anonymous
in reply to: Anonymous

I know how to do it now.

totu, thank you for your posting anyway.
Zhongwei Xia

"Zhongwei Xia" wrote in message
news:4884810@discussion.autodesk.com...
Hi,

I'm trying to insert a block with attributes into drawing file model spacel.
I can only see the block, and can't get the attributes inserted. I think I
need to loop check the block definition, find attribute definitions in it,
and insert these attributes.

Following is the code to do insert block:
Autodesk.AutoCAD.DatabaseServices.BlockReference blkRef = new
BlockReference(insPnt, blockID);



using (Transaction myT = tm.StartTransaction())

{

BlockTable bt =
(BlockTable)tm.GetObject(currentdb.BlockTableId,OpenMode.ForRead, false);

BlockTableRecord btr =
(BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite,false);

btr.AppendEntity(blkRef);

tm.AddNewlyCreatedDBObject(blkRef, true);

myT.Commit();

}



Thank you for any helps.

Zhongwei Xia
Message 4 of 4
kairat.galiyev
in reply to: Anonymous

Hello!
I have same problem, but i don't know similar solution.
If it possible, please, send me mail, or publish your solution at the this forum.

my mail kairat.galiyev@gmail.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost