<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Foundation Tag Rotate to match footing ElementTransformUtils.RotateElement(doc, tag.Id, rotationLine, rotateValue); in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10792095#M22058</link>
    <description>&lt;P&gt;Hi, before running the code try go to the family editor (edit family) of &lt;EM&gt;Structural Foundation Tags&lt;/EM&gt; and go to the "Family Category and Parameters" window.&lt;/P&gt;&lt;P&gt;Try to check the setting "Rotate with component".&lt;/P&gt;&lt;P&gt;Save or load the family back into in the project document and then run the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sochong_1-1638311963355.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/995518iDC2B62C8DF9019A3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sochong_1-1638311963355.png" alt="sochong_1-1638311963355.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sochong_0-1638312863925.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/995522i4A514E451B1BF656/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sochong_0-1638312863925.png" alt="sochong_0-1638312863925.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Nov 2021 22:55:02 GMT</pubDate>
    <dc:creator>so-chong</dc:creator>
    <dc:date>2021-11-30T22:55:02Z</dc:date>
    <item>
      <title>Foundation Tag Rotate to match footing ElementTransformUtils.RotateElement(doc, tag.Id, rotationLine, rotateValue);</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10791940#M22056</link>
      <description>&lt;P&gt;The below code runs without error. However, the tags are not rotated via the below code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ElementTransformUtils.RotateElement(doc, tag.Id, rotationLine, rotateValue);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="foundation tags not matching footing rotation" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/995489iF0463FC1C8498FCD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FootingTagNotRotated.png" alt="foundation tags not matching footing rotation" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;foundation tags not matching footing rotation&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;

namespace RevitMcLaren
{
    [TransactionAttribute(TransactionMode.Manual)]
    public class FootingTagIsolated : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //Get UIDocument
            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            //Get Document
            Document doc = uidoc.Document;

            //Tag Parameters
            TagMode tmode = TagMode.TM_ADDBY_CATEGORY;
            TagOrientation tOrient = TagOrientation.Horizontal;

            List&amp;lt;BuiltInCategory&amp;gt; cats = new List&amp;lt;BuiltInCategory&amp;gt;();
            cats.Add(BuiltInCategory.OST_StructuralFoundation);

            ElementMulticategoryFilter filter = new ElementMulticategoryFilter(cats);

            IList&amp;lt;Element&amp;gt; tElements = new FilteredElementCollector(doc, doc.ActiveView.Id)
                .WherePasses(filter)
                .WhereElementIsNotElementType()
                .ToElements();


                try
            {
                using (Transaction trans = new Transaction(doc, "Tag Elements"))
                {
                    trans.Start();

                    //Tag Elements
                    foreach (Element ele in tElements)
                    {
                        //Retrieve Element
                        ElementId eleId = ele.Id; //element Id is a value not an object
                        Element eleNDoc = doc.GetElement(eleId); //element in document is a selected selement by value(Id)

                        //Get Parameter
                        //Parameter pWidth = eleNDoc.LookupParameter("Width"); //Get parameter of Foundation
                        string pWidth = eleNDoc.LookupParameter("Width").AsValueString(); //Get parameter's value as a string of Foundation
                        string pLength = eleNDoc.LookupParameter("Length").AsValueString(); //Get parameter of Foundation

                        //Use of external class ConvertFeetInches to get sum of feet plus inches as inches
                        var pWidthOut = ConvertFeetToInches.ToInches(pWidth);
                        var pLengthOut = ConvertFeetToInches.ToInches(pLength);

                        //Get Foundation LocationPoint (center of footing)
                        Reference refe = new Reference(ele);
                        LocationPoint loc = ele.Location as LocationPoint;
                        XYZ point = loc.Point;
                        var pointX = loc.Point.X;
                        var pointY = loc.Point.Y;
                        var pointZ = loc.Point.Z;

                        //Create new variables for later use out of "if" scope
                        double newpointX;
                        double newpointY;

                        //If point is negitive add, if positive subtract (to achive bottom right orientation)
                        //The divide by 2 is half of the original Width and Length parameter
                        if (pointX &amp;lt; 0)
                        {
                            newpointX = pointX + ((pWidthOut / 12)/2);
                        }
                        else
                        {
                            newpointX = pointX - ((pWidthOut / 12) / 2);
                        }

                        if (pointY &amp;lt; 0)
                        {
                            newpointY = pointY + ((pLengthOut / 12) / 2);
                        }
                        else
                        {
                            newpointY = pointY - ((pLengthOut / 12) / 2);
                        }                        
                        
                        //Create new point to place tag at (bottom right of footing)
                        XYZ updatedPoint = new XYZ(newpointX, newpointY, pointZ);

                        //create new point same as previous but with a increased Z. use the two points to create a line to use as an axis of rotation
                        XYZ updatedZ = new XYZ(newpointX, newpointY, (updatedPoint.Z+1));
                        Line rotationLine = Line.CreateBound(updatedPoint, updatedZ);

                        //Get the foundations locationPoint rotation, for use in rotating tag to match
                        var rotateValue = (ele.Location as LocationPoint).Rotation;

                        //Create new tag
                        IndependentTag tag = IndependentTag.Create(doc, doc.ActiveView.Id, refe, false, tmode, tOrient, updatedPoint);

                        //Rotate Tag
                        ElementTransformUtils.RotateElement(doc, tag.Id, rotationLine, rotateValue);

                        //Delete when done, use as a visual check
                        TaskDialog.Show("Values", "" + updatedPoint + ", " + updatedZ);
                    }

                    trans.Commit();
                }

                return Result.Succeeded;
            }
            catch (Exception e)
            {
                message = e.Message;
                return Result.Failed;
            }

        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for taking the time!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reference:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.revitapidocs.com/2019/3968f4e8-759c-f975-6c1f-7de42be633ed.htm" target="_blank" rel="noopener"&gt;https://www.revitapidocs.com/2019/3968f4e8-759c-f975-6c1f-7de42be633ed.htm&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static void RotateElement(
	Document document,
	ElementId elementToRotate,
	Line axis,
	double angle
)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Nov 2021 21:41:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10791940#M22056</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-30T21:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Foundation Tag Rotate to match footing ElementTransformUtils.RotateElement(doc, tag.Id, rotationLine, rotateValue);</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10792041#M22057</link>
      <description>&lt;P&gt;Foundation Tags do not rotate with the components prior to Revit 2022 (although I haven't tested it in Revit 2022). To get around this, you would have to create a custom tag with the label already rotated. Or you can just keep the tags horizontal and use an arrow to point to the element you're tagging.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 22:13:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10792041#M22057</guid>
      <dc:creator>StephenSmith-WPM</dc:creator>
      <dc:date>2021-11-30T22:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Foundation Tag Rotate to match footing ElementTransformUtils.RotateElement(doc, tag.Id, rotationLine, rotateValue);</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10792095#M22058</link>
      <description>&lt;P&gt;Hi, before running the code try go to the family editor (edit family) of &lt;EM&gt;Structural Foundation Tags&lt;/EM&gt; and go to the "Family Category and Parameters" window.&lt;/P&gt;&lt;P&gt;Try to check the setting "Rotate with component".&lt;/P&gt;&lt;P&gt;Save or load the family back into in the project document and then run the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sochong_1-1638311963355.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/995518iDC2B62C8DF9019A3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sochong_1-1638311963355.png" alt="sochong_1-1638311963355.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sochong_0-1638312863925.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/995522i4A514E451B1BF656/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sochong_0-1638312863925.png" alt="sochong_0-1638312863925.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 22:55:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10792095#M22058</guid>
      <dc:creator>so-chong</dc:creator>
      <dc:date>2021-11-30T22:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Foundation Tag Rotate to match footing ElementTransformUtils.RotateElement(doc, tag.Id, rotationLine, rotateValue);</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10792340#M22059</link>
      <description>&lt;P&gt;I tried this, and either way, it has no effect in 19 &amp;amp; 20?&amp;nbsp; In Revit 21 &amp;amp; 22 it works well. I had hoped the API could get the job done. Maybe not. Thanks for the reply &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3911986"&gt;@StephenSmith-WPM&lt;/a&gt;&amp;nbsp;&amp;amp; &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1263196"&gt;@so-chong&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&lt;div class="video-embed-center video-embed"&gt;&lt;iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FSrpnwJoz83I%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DSrpnwJoz83I&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FSrpnwJoz83I%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" width="200" height="112" scrolling="no" title="Revit 2021: Rotate Tag with Component Improvements" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture" allowfullscreen="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 02:44:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/foundation-tag-rotate-to-match-footing-elementtransformutils/m-p/10792340#M22059</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-12-01T02:44:36Z</dc:date>
    </item>
  </channel>
</rss>

