.NET

Reply
Valued Contributor
Ertqwa
Posts: 99
Registered: ‎10-03-2011
Message 1 of 2 (342 Views)
Accepted Solution

Insert wblock - annotative

342 Views, 1 Replies
01-19-2012 01:00 PM

Hello forum,

 

I use the following code to insert a wblock:

 

using (dbInsert = new Database(false, true))
{
    dbInsert.ReadDwgFile(strDwgPath, System.IO.FileShare.Read, true, "");
    oidInsert = dbActive.Insert(System.IO.Path.GetFileNameWithoutExtension(strDwgPath), dbInsert, true);
}

 Works as it should, and I can create a reference and use it. But when strDwgPath is an annotative block, it is inserted as a non-annotative block (BlockReference.Annotative == false).

 

I can use the following code, but then ALL blocks are inserted as annotative:

 

// Get the new blocktablerecord.
btrInsert = transActive.GetObject(oidInsert, OpenMode.ForWrite) as BlockTableRecord;
btrInsert.Annotative = AnnotativeStates.True;

 

How am I suppose to insert a wblock so annotative wblocks will be annotative and non-annotatives wont be?

 

Thank you.

 

bool bIsAnnotative = false;
using (dbInsert = new Database(false, true))
{
dbInsert.ReadDwgFile(strDwgPath, System.IO.FileShare.Read, true, "");
oidInsert = dbActive.Insert(System.IO.Path.GetFileNameWithoutExtension(strDwgPath), dbInsert, true);
bIsAnnotative = dbInsert.AnnotativeDrawing;
}

 

will help you i think. then

 

// Get the new blocktablerecord.
btrInsert = transActive.GetObject(oidInsert, OpenMode.ForWrite) as BlockTableRecord;
if (bIsAnnotative)
btrInsert.Annotative = AnnotativeStates.True;

 


 


Active Contributor
cincir
Posts: 32
Registered: ‎08-12-2011
Message 2 of 2 (338 Views)

Re: Insert wblock - annotative

01-19-2012 01:51 PM in reply to: Ertqwa

 

bool bIsAnnotative = false;

using (dbInsert = new Database(false, true))
{
    dbInsert.ReadDwgFile(strDwgPath, System.IO.FileShare.Read, true, "");
    oidInsert = dbActive.Insert(System.IO.Path.GetFileNameWithoutExtension(strDwgPath), dbInsert, true);
    bIsAnnotative = dbInsert.AnnotativeDrawing;
}

 

will help you i think. then

 

// Get the new blocktablerecord.
btrInsert = transActive.GetObject(oidInsert, OpenMode.ForWrite) as BlockTableRecord;
if (bIsAnnotative)
    btrInsert.Annotative = AnnotativeStates.True;

 


 


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.