Author Topic: AMEP Interference  (Read 5800 times)

0 Members and 1 Guest are viewing this topic.

MexicanCustard

  • Swamp Rat
  • Posts: 705
AMEP Interference
« on: May 27, 2011, 07:25:51 PM »
In AMEP Im trying to tell when a Pipe object passes through a Wall object or a Slab object(so I can sleeve it). Whats the most efficient method since Im doing this inside of a ObjectAppended or an ObjectModified event?
Revit 2019, AMEP 2019 64bit Win 10

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: AMEP Interference
« Reply #1 on: May 31, 2011, 03:55:59 PM »
I'm bumping my post since "Interference Detection" seems to be taboo in .NET.  Everyone who's figured it out must be keeping the info to themselves to make a profit.  There may be something in LISP but I can't read that gibberish.

Even after a thorough search on the interwebs I can't find anything.  There is some information about IntersectsWith() but within those articles/post someone always comments that these are 2D only.  AMEP has a neat little interference detection dialog, isn't there API to go along with it?

So if I have a vertical Pipe going through a horizontal Slab, will the IntersectsWith() work if they are both drawn in the same plane(doesn't work in MgdDbg or its C++ counterpart)?  Someone out there has to be able to point me in the right direction.
Revit 2019, AMEP 2019 64bit Win 10

bieres

  • Guest
Re: AMEP Interference
« Reply #2 on: June 01, 2011, 12:40:11 PM »
Hi MexicanCustard,

If you could try Solid3d Interference.
Using the method of Solid3d CheckInterference.
With that you would know if there is interference and you might get it.

Hola, si son Solid3d podrias intentar con Interferencia.
Usando el metodo CheckInterference de los Solid3d.
Con eso sabrias si hay interferencia y podrias obtenerla.


MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: AMEP Interference
« Reply #3 on: June 01, 2011, 04:21:02 PM »
Thank you for replying, I was starting to wonder if there was a solution.

I'll try your suggestion and post what I find. I'm also going to try the BREP route and see if Slabs and Pipes can be used in BREP routines.
Revit 2019, AMEP 2019 64bit Win 10

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: AMEP Interference
« Reply #4 on: June 01, 2011, 08:45:10 PM »
Ok, these three didn't work. So its back to the drawing board.

Point3dCollection pc = new Point3dCollection();
slab.IntersectWith(pipe, Intersect.ExtendBoth, pc, (System.IntPtr)1, (System.IntPtr) 1);

pc.Count is always 0

and:

Brep brp = new Brep(slab); <--- gives me a Boundary Exception
Hit[] hit = brp.GetLineContainment(new Line3d(pipe.StartPoint, pipe.EndPoint), 10);

and:

Solid3d s3slab = new Solid3d();
Solid3d s3pipe = new Solid3d();
s3slab.CreateFrom(slab); <-- eInvalidInput Exception
s3pipe.CreateFrom(pipe);

bool chk = s3slab.CheckInterference(s3pipe);

« Last Edit: June 01, 2011, 08:57:13 PM by MexicanCustard »
Revit 2019, AMEP 2019 64bit Win 10

bieres

  • Guest
Re: AMEP Interference
« Reply #5 on: June 02, 2011, 08:48:58 AM »
Hi.

Upload a dwg with your objects to check.

Sube un dwg con tus objectos a comprobar.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: AMEP Interference
« Reply #6 on: June 02, 2011, 05:02:08 PM »
This is the drawing I've been using for my test.
Revit 2019, AMEP 2019 64bit Win 10

Jeff H

  • Needs a day job
  • Posts: 6150
Re: AMEP Interference
« Reply #7 on: June 03, 2011, 04:04:04 AM »
I hate this API it is the worst documented....................I will stop complaining

I think I am getting some where,

To get started off simple,
to test delete all objects in drawings except for the one slab and one pipe that goes through slab.(Make sure only 1 pipe object and 1 slab object in drawing and they intersect)


Code: [Select]
        [CommandMethod("SlabbyCrappyInterference")]
        public void SlabbyCrappyInterference()
        {
            //SlabInterferenceOption

            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;
                Slab slb;

               
                ObjectId pipeId = ObjectId.Null;
                ObjectId slabId = ObjectId.Null;
               
                foreach (ObjectId objId in currentSpace)
                {
                   
                    if (objId.ObjectClass.Name == "AecbDbPipe")
                    {
                        pipeId = objId;

                    }

                    if (objId.ObjectClass.Name == "AecDbSlab")
                    {
                        slabId = objId;
                    }
                }

                slb = trx.GetObject(slabId, OpenMode.ForWrite) as Slab;

                SlabInterference si = new SlabInterference();
                si.EntityId = pipeId;

                ObjectIdCollection objIdColl = new ObjectIdCollection();
                si.SetEntityBlockRefPath(pipeId, objIdColl, null);

                si.Option = SlabInterferenceOption.Add;

                slb.Interferences.Add(si);

                trx.Commit();


            }

        }


Jeff H

  • Needs a day job
  • Posts: 6150
Re: AMEP Interference
« Reply #8 on: June 03, 2011, 05:04:38 AM »
Now for the wall and same thing one wall and one pipe

Next will try all pipes, walls, slabs however many.

Code: [Select]

        [CommandMethod("WallCheck")]
        public void WallCheck()
        {
            //SlabInterferenceOption

            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;
                Wall wall;


                ObjectId pipeId = ObjectId.Null;
                ObjectId wallId = ObjectId.Null;

                foreach (ObjectId objId in currentSpace)
                {

                    if (objId.ObjectClass.Name == "AecbDbPipe")
                    {
                        pipeId = objId;

                    }

                    if (objId.ObjectClass.Name == "AecDbWall")
                    {
                        wallId = objId;
                    }

                }

                wall = trx.GetObject(wallId, OpenMode.ForWrite) as Wall;

                WallInterference wi = new WallInterference();
                wi.EntityId = pipeId;

                ObjectIdCollection objIdColl = new ObjectIdCollection();
                wi.SetEntityBlockRefPath(pipeId, objIdColl, null);

                wi.ShrinkWrapEffect = WallShrinkWrapEffect.Additive;

                wall.WallInterferences.Add(wi);

                trx.Commit();


            }

        }



Jeff H

  • Needs a day job
  • Posts: 6150
Re: AMEP Interference
« Reply #9 on: June 03, 2011, 07:48:03 AM »
Code: [Select]
        [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();

            }

        }


Jeff H

  • Needs a day job
  • Posts: 6150
Re: AMEP Interference
« Reply #10 on: June 06, 2011, 07:31:28 PM »
Is it not working?

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: AMEP Interference
« Reply #11 on: June 07, 2011, 01:51:14 PM »
Sorry Jeff, I haven't had time to try out your code. I've been side tracked exporting properties out to a SQLite DB for our fabrication shop. Finished the test app today and should be able to get back to this problem this week. I'll definitely try out your code and post back my results. Thanks for helping me out.
Revit 2019, AMEP 2019 64bit Win 10

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: AMEP Interference
« Reply #12 on: June 07, 2011, 08:03:05 PM »
Code: [Select]
        [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();

            }

        }


Ok, this puts a hole in the slab, the size of the pipe, wherever the pipe goes thru. And it follows the pipe as if it were anchored. It's really neat, but how do I tell if there is an interference within code (without looking at the drawing and seeing the hole).
Revit 2019, AMEP 2019 64bit Win 10