Place a door tag at the centre of the door opening leaf

Place a door tag at the centre of the door opening leaf

Anonymous
727 Views
4 Replies
Message 1 of 5

Place a door tag at the centre of the door opening leaf

Anonymous
Not applicable

Hi Yall, 

 I am currently working on a problem. It seems simple enough but it is driving me up the wall. 

Revit as it stands, places Door tags over the centre line of the door threshold (2d), and I have to manually modify the door tags to fit within the opening space of the door leaf (the curvy part) opposite the hosting wall.

does anyone know a simple way of finding the centre point of a door opening and then applying a door tag to that point or if there is already a door tag there, moving it to that location? 

 

My Code as stand is the following. 

 

using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

namespace DoorTags
{
    [TransactionAttribute(TransactionMode.Manual)]
    [RegenerationAttribute(RegenerationOption.Manual)]
    public class doorTags : IExternalCommand
    {
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            //Get application and document objects
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;

            // Set cursor as hour glass
            Cursor.Current = Cursors.WaitCursor;

            Dim collector As Dictionary(Of String, List(Of DB.FamilyInstance)) = _
            New DB.FilteredElementCollector(doc).OfClass(GetType(DB.FamilyInstance)).OfCategory(DB.BuiltInCategory.OST_Doors).Cast(Of DB.FamilyInstance).GroupBy(Function(fi) fi.Symbol.Family.Name).ToDictionary(Of String, List(Of DB.FamilyInstance))
            (Function(f) f.Key, Function(f) f.ToList);

            // test if the family name string contains "single"
            Dim searchString as String = "Single";

            for Each key as String in collector.Keys
                if key.Contains(searchString, StringComparison.CurrentCultureIgnoreCase)
                {
                    //Get door current location 
                    LocationPoint DoorLocation = OST.Doors.Location as LocationPoint;

                    XYZ oldPlace = DoorLocation.Point;

                    //Get door swing direction 

                    // calculate new door tag location 
                    if (condition) // tag already exists
                    {
                      
                        XYZ DoorTagPlace = new XYZ();
                        ElementTransformUtils.MoveElement(document, column.Id, newPlace); (condition)
                    }
                    else
                    {
                        then(condition)// no door tag exisiting
                    }
                    //find the direction of the door opening which will help us work out where to place the door tag
                    bool condition = true; // the door swings inward, place the door tag on the inside of the door relative to the centre of the hosting door. 
                    if (condition)
                    {
                        // move door tag to the inside of the wall to the centre of the opening door leaf
                    }
                    else
                    {
                        // move the door tag to the outside of the wall to the centre of the opening door leaf
                    }
                }
            // Set cursor as default arrow
            Cursor.Current = Cursors.Default;
        }
    }
}

I am also placing a timer for the operation, so the more efficient my method, the better. any help would be greatly appreciated. 

 

 

 

0 Likes
728 Views
4 Replies
Replies (4)
Message 2 of 5

BobbyC.Jones
Advocate
Advocate

I'm not sure I completely understand your requirements, but it sounds like you're trying to find the centroid of the triangle formed by the door opening and the door leaf.

--
Bobby C. Jones
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Bobby, 

 Yes that is what I am after. From that I want to place a door tag at that position, if there is already a door tag there, then move the door tag to that position. Does that make more sense now?

0 Likes
Message 4 of 5

Anonymous
Not applicable
Yes that is right. I want to find the central and then place the door tag
at that point.
0 Likes
Message 5 of 5

BobbyC.Jones
Advocate
Advocate

@Anonymous wrote:

Hi Bobby, 

 Yes that is what I am after. From that I want to place a door tag at that position, if there is already a door tag there, then move the door tag to that position. Does that make more sense now?


I think the triangle centroid formula in my previous link is pretty straight forward to implement, and I see that in another post @Revitalizer has provided a  direction that could also prove to be fairly easy to implement.  As for determining if the door is already tagged, @jeremytammik has some info on The Building Coder blog.  Does that give you enough direction, or is there something more specific you're stuck on?

--
Bobby C. Jones
0 Likes