Message 1 of 7
Explode a block containing the nested array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
How to correctly explode a block so that the nested array does not escape from its original place after calling ExplodeToOwnerSpace? My observations show that the array from the exploded block is shifted relative to the original by the double coordinates of the block insertion point (owner).
Below is the original block. The colored elements are array:
After ExplodeToOwnerSpace:
Original drawing is attached.
I can make a correction for arrays, but maybe there is another way?
My code:
[CommandMethod( "testExplodeToOwnerSpace", CommandFlags.Modal )]
public void testExplodeToOwnerSpace() // This method can have any name
{
// Put your command code here
try
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityOptions peo = new PromptEntityOptions( "\nPick a block: " );
peo.SetRejectMessage( "\nThis is not a block!" );
peo.AddAllowedClass( typeof( BlockReference ), true );
PromptEntityResult per = ed.GetEntity( peo );
if( per.Status != PromptStatus.OK )
{
return;
}
using( Transaction tr = doc.TransactionManager.StartTransaction() )
{
BlockTableRecord curSpc = tr.GetObject( db.CurrentSpaceId, OpenMode.ForWrite ) as BlockTableRecord;
BlockReference blRef = tr.GetObject( per.ObjectId, OpenMode.ForWrite ) as BlockReference;
blRef.ExplodeToOwnerSpace();
blRef.Erase( true );
tr.Commit();
}
}
catch( System.Exception ex )
{
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage( ex.ToString() );
}
}