- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have an array within which I have multiple blocks.
I need to explode the array and delete blocks within a given area. Currently this area is being calculated around a selected point.
I'm using PromptSelectionResult psr = Active.Editor.SelectCrossingPolygon(collection); to get the array at first and then using the same again to get the blocks.
But it is detecting the array without an issue and I'm then exploding the array. After exploding the array with "exploded = AssocArray.Explode(rackArray.Id);" I'm running SelectCrossPolygon() again with the same point collection, but it is not returning any blocks.
I tried using two different transactions and same transaction but there is no change in this behavior.
When I manually explode the block before I run the command the with the second part only, then it is selecting the blocks properly as expected, but not when doing it through code.
//Code for detection and expolosion of array block
using (Transaction tr1 = Active.Database.TransactionManager.StartUndoGroupTransaction())
{
BlockReference rackArray = GetOverlappingRackArray(tr1);
if (rackArray == null)
{
return;
}
Matrix3d rackMatrixInverted = rackArray.BlockTransform.Inverse();
ObjectIdCollection exploded = new ObjectIdCollection();
if (AssocArray.IsAssociativeArray(rackArray.Id))
exploded = AssocArray.Explode(rackArray.Id);
//foreach (ObjectId id in exploded)
//{
// Entity ent = (Entity)tr1.GetObject(id, OpenMode.ForWrite);
// //modelSpace.AppendEntity(ent);
// //tr.AddNewlyCreatedDBObject(ent, true);
//}
tr1.Commit();
}// code for detecting the new exploded blocks
using (Transaction tr = Active.Database.TransactionManager.StartUndoGroupTransaction())
{
ObjectIdCollection overlapped = FindOverlappingBlocks();
foreach (ObjectId id in overlapped)
{
Active.Editor.WriteMessage(id.ToString());
Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
ent.Erase();
}
tr.Commit();
}
// Code for detection of entities.
PromptSelectionResult psr = Active.Editor.SelectCrossingPolygon(collection);
if (psr.Status != PromptStatus.OK)
{
Active.WriteError("selection failed");
return null;
}
SelectionSet ss = psr.Value;
ObjectIdCollection intersectingObjects = new ObjectIdCollection();
foreach (SelectedObject so in ss)
{
intersectingObjects.Add(so.ObjectId);
}
return intersectingObjects;Edit: Note that all of this is wrapped in another transaction, so the transactions above are nested within.
Could anyone please let me know what I'm missing here?
Thanks for the help in advance.
Solved! Go to Solution.