Find the walls which are intersecting or not going till the bottom of beam

Find the walls which are intersecting or not going till the bottom of beam

Anonymous
Not applicable
1,124 Views
11 Replies
Message 1 of 12

Find the walls which are intersecting or not going till the bottom of beam

Anonymous
Not applicable

I want to find that walls which is intersecting or not going till the bottom of the beam. How can I find that?

0 Likes
1,125 Views
11 Replies
Replies (11)
Message 2 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

Please provide a sample RVT file.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 12

Anonymous
Not applicable

I want to create addin for this.

0 Likes
Message 4 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

OK I need a sample Revit project (RVT) to test on it.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 5 of 12

Anonymous
Not applicable

.Rvt File

0 Likes
Message 6 of 12

Charles.Piro
Advisor
Advisor

Hi,

 

 

you can use this for start :

 

[Transaction(TransactionMode.Manual)]
    public class ResaAuto : IExternalCommand
    {
        public struct InterBeamWall
        {
            public FamilyInstance beam;
            public Wall wall;
        }
        private List<InterBeamWall> lstInterBeamWall;
        public List<InterBeamWall> _lstInterBeamWall
        {
            get
            {
                return lstInterBeamWall;
            }
        }

        public Result Execute(ExternalCommandData extCmdData, ref string msg, ElementSet elmntSet)
        {
            UIApplication uiapp = extCmdData.Application;
            UIDocument uiDoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uiDoc.Document;

            FilteredElementCollector FltCollwall = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls);

            foreach (Element elmntWall in FltCollwall)
            {
                try
                {
                    BoundingBoxXYZ bbXYZ = elmntWall.get_BoundingBox(doc.ActiveView);
                    Outline outlineWall = new Outline(bbXYZ.Min, bbXYZ.Max);

                    BoundingBoxIntersectsFilter intersectsFilter = new BoundingBoxIntersectsFilter(outlineWall);

                    FilteredElementCollector fltCollBeam = new FilteredElementCollector(doc);
                    fltCollBeam.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_StructuralFraming).WherePasses(intersectsFilter);

                    foreach (Element _beam in fltCollBeam)
                    {
                        try
                        {
                            FamilyInstance beam = _beam as FamilyInstance;
                            if (beam != null)
                            {
                                InterBeamWall intersection;
                                intersection.beam = beam;
                                intersection.wall = elmntWall as Wall;
                                lstInterBeamWall.Add(intersection);
                            }
                            else
                                continue;
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                    }
                }
                catch (Exception)
                {
                    continue;
                }

            }
            return Result.Succeeded;
        }
    }
                   

Smiley Wink



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 7 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

What is the Class of "InterBeamWall"??? What version of API??


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 8 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

Pleas try this code and tell me if it works the way you want

 

#region Namespaces

using System;
using System.Text;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
using System.IO;

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Plumbing;

using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.UI.Events;

using Autodesk.Revit.Exceptions;
using Autodesk.Revit.Utility;

using RvtApplication = Autodesk.Revit.ApplicationServices.Application;
using RvtDocument = Autodesk.Revit.DB.Document;

#endregion

namespace RevitAddinCS2
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class ExtCmd : IExternalCommand
    {
        #region Cached Variables

        private static ExternalCommandData _cachedCmdData;

        public static UIApplication CachedUiApp
        {
            get
            {
                return _cachedCmdData.Application;
            }
        }

        public static RvtApplication CachedApp
        {
            get
            {
                return CachedUiApp.Application;
            }
        }

        public static RvtDocument CachedDoc
        {
            get
            {
                return CachedUiApp.ActiveUIDocument.Document;
            }
        }

        #endregion

        #region IExternalCommand Members

        public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet)
        {
            _cachedCmdData = cmdData;

            try
            {

                FilteredElementCollector WallCollector = new FilteredElementCollector(CachedDoc);
                WallCollector.OfClass(typeof(Wall)).WhereElementIsNotElementType();
                List<Wall> walls = WallCollector.Cast<Wall>().ToList();

                StringBuilder sb = new StringBuilder();

                foreach (Element wall in walls)
                {
                    GeometryElement geomElement = wall.get_Geometry(new Options());

                    Solid solid = null;

                    foreach (GeometryObject geomObj in geomElement)
                    {
                        solid = geomObj as Solid;

                        if (solid != null)
                        {
                            FilteredElementCollector BeamCollector = new FilteredElementCollector(CachedDoc);
                            BeamCollector.OfCategory(BuiltInCategory.OST_StructuralFraming).WhereElementIsNotElementType();
                            BeamCollector.WherePasses(new ElementIntersectsSolidFilter(solid)); // Apply intersection filter to find matches

                            List<Element> beams = BeamCollector.Cast<Element>().ToList();

                            if (beams.Count > 0)
                            {
                                foreach (Element beam in beams)
                                {
                                    sb.AppendLine(string.Format("Wall: {0} with Id: {1} intersects with Beam: {2} with Id: {3}", wall.Name, wall.Id.ToString(), beam.Name, beam.Id.ToString()));
                                }
                            }

                            break;
                        }
                    }
                }

                TaskDialog.Show("Revit", sb.ToString());

                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                msg = ex.ToString();
                return Result.Failed;
            }
        }

        #endregion

    }
}

Please don't forget to mark this reply as an answer if it satisfies your needs.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 9 of 12

Charles.Piro
Advisor
Advisor

Hi mustafa,

 

it's not a Class. It's an object "Struct" : Microsoft

 

Smiley Wink



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 10 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

Ok I didn't notice that you have defined the Struct in the top of the code because my mouse scroll down accidentally Smiley Very Happy

Nice Work anyway. Smiley LOL


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 11 of 12

Charles.Piro
Advisor
Advisor

Ah ok !! : Smileyvery-happy:

 

Thanks, nice work too!



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 12 of 12

jeremytammik
Autodesk
Autodesk

The Revit API provides the ReferenceIntersector class to search for element intersections:

 

http://www.revitapidocs.com/2017/36f82b40-1065-2305-e260-18fc618e756f.htm

 

Here is a full explanation of using it:

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2018/ENU/Revit-API/files/GUID-...

 

Here is a full-fledged example using the ReferenceIntersector to determine a point on a neighbouring, parallel wall to create dimensioning:

http://thebuildingcoder.typepad.com/blog/2011/02/dimension-walls-using-findreferencesbydirection.htm...

It uses the ReferenceIntersector class to determine a point on a neighbouring, parallel wall to create dimensioning.

At that time, the method was called FindReferencesByDirection. It was later wrapped in the ReferenceIntersector class. The external command CmdDimensionWallsFindRefs demonstrating its use has been updated to use the new class and is available in The Building Coder samples on GitHub:

https://github.com/jeremytammik/the_building_coder_samples

I hope this helps.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes