Can't cut join element issue

Can't cut join element issue

Anonymous
Not applicable
1,852 Views
8 Replies
Message 1 of 9

Can't cut join element issue

Anonymous
Not applicable
When I joining the structural column and floor it gives warning that can't cut join element.Why this warning is occurred? What should I write in this code for ignoring this warning? This my code which I am using for joining the elements: UIApplication uiApp = commandData.Application; UIDocument uidoc = uiApp.ActiveUIDocument; Document doc = uidoc.Document; using (Transaction t = new Transaction(doc, "Join All Walls/Floors")) { t.Start(); FilteredElementCollector col = new FilteredElementCollector(doc, doc.ActiveView.Id); col.OfClass(typeof(FamilyInstance)); col.OfCategory(BuiltInCategory.OST_StructuralColumns); foreach (FamilyInstance column in col) { // get the bounding box of this wall // BoundingBoxXYZ bbox = column.get_BoundingBox(null); // create an outline from the min and max points of the bounding box // Outline outline = new Outline(bbox.Min, bbox.Max); // find all floors that intersect the wall foreach (Element floor in new FilteredElementCollector(doc) .OfClass(typeof(Floor)) .WherePasses(new ElementIntersectsElementFilter(column))) { check = JoinGeometryUtils.AreElementsJoined(doc, column, floor); if(check==true) { } else { JoinGeometryUtils.JoinGeometry(doc, column, floor); JoinGeometryUtils.SwitchJoinOrder(doc, column, floor); } } } t.Commit(); } return Result.Succeeded; }
0 Likes
1,853 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

When I joining the structural column and floor it gives warning that can't cut join element.Why this warning is occurred?

What should I write in this code for ignoring this warning?

 

 

 

 

 

This my code which I am using for joining the elements:

 

 

 

 

 

UIApplication uiApp = commandData.Application;

UIDocument uidoc = uiApp.ActiveUIDocument;

Document doc = uidoc.Document;

using (Transaction t = new Transaction(doc, "Join All Walls/Floors"))

{

t.Start();

FilteredElementCollector col = new FilteredElementCollector(doc, doc.ActiveView.Id);

col.OfClass(typeof(FamilyInstance));

col.OfCategory(BuiltInCategory.OST_StructuralColumns);

foreach (FamilyInstance column in col)

{

// get the bounding box of this wall

// BoundingBoxXYZ bbox = column.get_BoundingBox(null);

// create an outline from the min and max points of the bounding box

// Outline outline = new Outline(bbox.Min, bbox.Max);

// find all floors that intersect the wall

foreach (Element floor in new FilteredElementCollector(doc) .OfClass(typeof(Floor)) .WherePasses(new ElementIntersectsElementFilter(column)))

{

check = JoinGeometryUtils.AreElementsJoined(doc, column, floor);

if(check==true)

{

}

else

{

JoinGeometryUtils.JoinGeometry(doc, column, floor);

JoinGeometryUtils.SwitchJoinOrder(doc, column, floor);

}

}

}

t.Commit();

}

return Result.Succeeded;

}

0 Likes
Message 3 of 9

Shai.Nguyen
Advocate
Advocate

same problem here. please help us!

0 Likes
Message 4 of 9

RPTHOMAS108
Mentor
Mentor

Some types of structural columns can't be joined e.g. steel I-Sections.

 

This and other things I believe was historically controlled by the parameter within the family 'Material for Model Behavior' (US Spelling, they hate U's!). If set to steel it wouldn't let you join it, other properties also changed. However just tried the change that parameter on one of the concrete sections families to prove this but no effect (it still joined). Fact remains that steel sections aren't meant to join with floors. Better family authors than me know how to prevent joining of steel sections and if these families exist in your project you won't be able to join them either.

 

If this is your issue then you need to inspect the parameter to join just the ones that are intended to be joined.

0 Likes
Message 5 of 9

Shai.Nguyen
Advocate
Advocate

It is not cause of steel column. It causes I import autocad and pick line. Some dwg drawings are not good so the volumn or clearance when 2 element intersect is too small and make error. Please see attachment rvt.

cant.png

0 Likes
Message 6 of 9

Mustafa.Salaheldin
Collaborator
Collaborator

I tested the provided code with the provided Revit sample file and it worked fine.

 

The file only contains this portion:

cancutjoined.png

The other parts were hidden so I'll test them also.


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

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 7 of 9

Mustafa.Salaheldin
Collaborator
Collaborator

Even after I showed the hidden elements I couldn't reproduce the issue. I drew a floor on top of all the beams and it worked flawlessly.

 

When I adjusted the code to get the intersection between beams and columns then the error message appeared.

 

Here is the code that solved the problem:

 

#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.Collections;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.Utility;

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

#endregion

namespace Toolbox
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class CutJoinElement : 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
            {
                //TODO: add your code below.
                using (Transaction t = new Transaction(CachedDoc, "Join All Walls/Floors"))

                {
                    FailureHandlingOptions options = t.GetFailureHandlingOptions();
                    WarningsDiscard preproccessor = new WarningsDiscard();
                    options.SetFailuresPreprocessor(preproccessor);
                    t.SetFailureHandlingOptions(options);

                    t.Start();

                    FilteredElementCollector col = new FilteredElementCollector(CachedDoc, CachedDoc.ActiveView.Id);

                    col.OfClass(typeof(FamilyInstance));

                    col.OfCategory(BuiltInCategory.OST_StructuralFraming);

                    foreach (FamilyInstance column in col)

                    {
                        foreach (Element floor in new FilteredElementCollector(CachedDoc).OfCategory(BuiltInCategory.OST_StructuralColumns).WherePasses(new ElementIntersectsElementFilter(column)))

                        {

                            bool check = JoinGeometryUtils.AreElementsJoined(CachedDoc, column, floor);

                            if (check == true)

                            {

                            }

                            else

                            {

                                JoinGeometryUtils.JoinGeometry(CachedDoc, column, floor);

                                JoinGeometryUtils.SwitchJoinOrder(CachedDoc, column, floor);

                            }

                        }

                    }

                    t.Commit();

                }

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

        #endregion
    }

    public class WarningsDiscard : IFailuresPreprocessor
    {
        FailureProcessingResult
          IFailuresPreprocessor.PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            String transactionName = failuresAccessor.GetTransactionName();
            IList<FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages();
            if (fmas.Count == 0)
            {
                return FailureProcessingResult.Continue;
            }
            bool isResolved = false;
            foreach (FailureMessageAccessor fma in fmas)
            {
                if (fma.HasResolutions())
                {
                    failuresAccessor.ResolveFailure(fma);
                }

                isResolved = true;
            }
            if (isResolved)
            {
                return FailureProcessingResult.ProceedWithCommit;
            }
            return FailureProcessingResult.Continue;
        }
    }

}

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


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

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

Message 8 of 9

Shai.Nguyen
Advocate
Advocate

Your code really works and easy to understand. With some change, I can join all element in project.

This is not my topic so I can't mark your answer as a solution. But I give you one kudo.

Thank you for your solution. I really appreciate it.

0 Likes
Message 9 of 9

Mustafa.Salaheldin
Collaborator
Collaborator

happy to hear it works for you and we will wait for @Anonymous to close the topic.


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

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes