[CommandMethod("WallSlabby")]
public void WallSlabby()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction trx = db.TransactionManager.StartTransaction())
{
BlockTable blocktable = trx.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;//Assign BlockTable
BlockTableRecord currentSpace = trx.GetObject(db.CurrentSpaceId, OpenMode.ForRead) as BlockTableRecord;
ObjectIdCollection pipeIds = new ObjectIdCollection();
ObjectIdCollection slabnWallIds = new ObjectIdCollection();
foreach (ObjectId objId in currentSpace)
{
if (objId.ObjectClass.Name == "AecbDbPipe")
{
pipeIds.Add(objId);
continue;
}
if (objId.ObjectClass.Name == "AecDbWall" || objId.ObjectClass.Name == "AecDbSlab")
{
slabnWallIds.Add(objId);
}
}
foreach (ObjectId slabnWallId in slabnWallIds)
{
if (slabnWallId.ObjectClass.Name == "AecDbSlab")
{
Slab slb = trx.GetObject(slabnWallId, OpenMode.ForWrite) as Slab;
SlabInterferenceCollection sic = slb.Interferences;
foreach (ObjectId pipeId in pipeIds)
{
SlabInterference si = new SlabInterference();
si.EntityId = pipeId;
ObjectIdCollection objIdColl = new ObjectIdCollection();
si.SetEntityBlockRefPath(pipeId, objIdColl, null);
si.Option = SlabInterferenceOption.Add;
sic.Add(si);
}
}
else
{
Wall wall = trx.GetObject(slabnWallId, OpenMode.ForWrite) as Wall;
WallInterferenceCollection wic = wall.WallInterferences;
foreach (ObjectId pipeId in pipeIds)
{
WallInterference wi = new WallInterference();
wi.EntityId = pipeId;
ObjectIdCollection objIdColl = new ObjectIdCollection();
wi.SetEntityBlockRefPath(pipeId, objIdColl, null);
wi.ShrinkWrapEffect = WallShrinkWrapEffect.Additive;
wic.Add(wi);
}
}
}
trx.Commit();
}
}