<?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: viewport position in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7155789#M59102</link>
    <description>&lt;P&gt;there is no API method available to get / set&amp;nbsp;the position of the ViewPort Title and ExtensionLine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far&amp;nbsp;as I know,&amp;nbsp;&amp;nbsp;what you want, can't be done.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 19:58:53 GMT</pubDate>
    <dc:creator>FAIR59</dc:creator>
    <dc:date>2017-06-15T19:58:53Z</dc:date>
    <item>
      <title>viewport position</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7009686#M59097</link>
      <description>&lt;P&gt;How can I get viewport position....&lt;/P&gt;&lt;P&gt;I am using boudarybox get min max and then I can get the center position..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I have viewport with name with underline&amp;nbsp; and then I drag the line point the boundarybox get the max size of this viewport this line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get center point of this viewport and how can I get the size of this line?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;attached file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then the possition is wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 16:00:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7009686#M59097</guid>
      <dc:creator>sonicer</dc:creator>
      <dc:date>2017-04-11T16:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: viewport position</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7028245#M59098</link>
      <description>&lt;P&gt;the first part, getting the "clean" boundingbox is simple. Hide the label and extensionline with the TTT (temporary transaction trick) and determine the boundingbox.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public BoundingBoxXYZ Get_BoundingBox_Clean(Viewport viewport)
        {
            if (viewport == null) return null;
            Document doc = viewport.Document;
            string sheetName = viewport.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NAME).AsString();
            List&amp;lt;ViewSheet&amp;gt; _sheets = new FilteredElementCollector(doc)
            .OfClass(typeof(ViewSheet))
            .Cast&amp;lt;ViewSheet&amp;gt;()
            .Where(e =&amp;gt; e.Name.Equals(sheetName))
            .ToList();
            Autodesk.Revit.DB.View sheetview = _sheets.FirstOrDefault();

            ElementType porttype = doc.GetElement(viewport.GetTypeId()) as ElementType;
            Parameter _showExtensionLine = porttype.get_Parameter(BuiltInParameter.VIEWPORT_ATTR_SHOW_EXTENSION_LINE);
            Parameter _labelTag = porttype.get_Parameter(BuiltInParameter.VIEWPORT_ATTR_LABEL_TAG);
            BoundingBoxXYZ bb = null;
            using (Transaction t = new Transaction(doc, "viewport"))
            {
                t.Start();
                using (SubTransaction st = new SubTransaction(doc))
                {
                    st.Start();
                    _showExtensionLine.Set((int)0);
                    _labelTag.Set(ElementId.InvalidElementId);
                    st.Commit();
                }
                using (SubTransaction st = new SubTransaction(doc))
                {
                    st.Start();
                    doc.Regenerate();
                    bb = viewport.get_BoundingBox(sheetview);
                    st.Commit();
                }
                t.RollBack();
            }
            return bb;
        }
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the second part requires more acrobatics.&lt;/P&gt;
&lt;P&gt;First hide the label, extension line and all annotations. Then make the cropbox as small as possible, and determine the boundingbox.&lt;/P&gt;
&lt;P&gt;This is the "zero state" for comparison.&lt;/P&gt;
&lt;P&gt;Next make the extension line Visible and&amp;nbsp;again determine the boundingbox. If the box.Min and box.Max have moved, we can&amp;nbsp;calculate the begin and&amp;nbsp;endpoint of the extension line. If not&amp;nbsp;(see picture: box.Min.X&amp;nbsp;&amp;nbsp;== box.Min.X -"zero state")&amp;nbsp;&amp;nbsp;&amp;nbsp;then reposition the cropbox and repeat.&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="extensionline.PNG" style="width: 387px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/346907i30371C0F932E7215/image-dimensions/387x330?v=v2" width="387" height="330" role="button" title="extensionline.PNG" alt="extensionline.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public Line Get_Viewport_Extension_Line(Viewport viewport)
        {
            try
            {

                if (viewport == null) return null;
                Document doc = viewport.Document;
                string sheetName = viewport.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NAME).AsString();
                List&amp;lt;ViewSheet&amp;gt; _sheets = new FilteredElementCollector(doc)
                .OfClass(typeof(ViewSheet))
                .Cast&amp;lt;ViewSheet&amp;gt;()
                .Where(e =&amp;gt; e.Name.Equals(sheetName))
                .ToList();
                Autodesk.Revit.DB.View sheetview = _sheets.FirstOrDefault();

                Autodesk.Revit.DB.View view = doc.GetElement(viewport.ViewId) as Autodesk.Revit.DB.View;

                ElementType porttype = doc.GetElement(viewport.GetTypeId()) as ElementType;
                Parameter _showExtensionLine = porttype.get_Parameter(BuiltInParameter.VIEWPORT_ATTR_SHOW_EXTENSION_LINE);
                Parameter _labelTag = porttype.get_Parameter(BuiltInParameter.VIEWPORT_ATTR_LABEL_TAG);

                BoundingBoxXYZ crop = view.CropBox;
                BoundingBoxXYZ newcrop = view.CropBox;

                BoundingBoxXYZ bb = null;
                XYZ pt1 = XYZ.Zero; XYZ pt2 = XYZ.Zero;

                using (TransactionGroup tg = new TransactionGroup(doc, "get_extensionline"))
                {
                    tg.Start();
                    using (Transaction t = new Transaction(doc, "crop_Min_clean"))
                    {
                        t.Start();
                        using (SubTransaction st = new SubTransaction(doc))
                        {
                            st.Start();
                            view.get_Parameter(BuiltInParameter.VIEWER_VOLUME_OF_INTEREST_CROP).Set(ElementId.InvalidElementId);
                            _showExtensionLine.Set((int)0);
                            _labelTag.Set(ElementId.InvalidElementId);
                            view.AreAnnotationCategoriesHidden = true;

                            porttype.get_Parameter(BuiltInParameter.VIEWPORT_ATTR_SHOW_BOX).Set((int)1);
                            porttype.get_Parameter(BuiltInParameter.VIEWPORT_ATTR_SHOW_LABEL).Set((int)1);
                            newcrop.Min = new XYZ(crop.Max.X - 0.02, crop.Max.Y - 0.02, crop.Min.Z);
                            newcrop.Max = new XYZ(crop.Max.X, crop.Max.Y, crop.Max.Z);
                            view.CropBox = newcrop;
                            view.CropBoxActive = true;
                            st.Commit();
                        }
                        doc.Regenerate();
                        t.Commit();
                    }

                    bb = viewport.get_BoundingBox(sheetview);
                    BoundingBoxXYZ testcrop = view.CropBox;

                    using (Transaction t = new Transaction(doc, "crop_Max"))
                    {
                        t.Start();
                        doc.Regenerate();
                        _showExtensionLine.Set((int)1);
                        t.Commit();
                    }
                    BoundingBoxXYZ bb2 = viewport.get_BoundingBox(sheetview);
                    bool MoveRight = bb.Min.X.CompareTo(bb2.Min.X) == 0;
                    bool moveLeft = bb.Max.X.CompareTo(bb2.Max.X) == 0;
                    bool moveUp = bb.Min.Y.CompareTo(bb2.Min.Y) == 0;
                    bool moveDown = bb.Max.Y.CompareTo(bb2.Max.Y) == 0;
                     
                    pt1 = new XYZ(bb2.Min.X, moveDown?  bb2.Min.Y: bb2.Max.Y, bb.Min.Z);
                    pt2 = new XYZ(bb2.Max.X, pt1.Y, bb.Min.Z);

                    if ( MoveRight || moveLeft || (moveUp &amp;amp;&amp;amp; moveDown))
                    {
                        using (Transaction t = new Transaction(doc, "crop_Max"))
                        {
                            t.Start();
                            doc.Regenerate();
                            double MoveX = MoveRight ? 100 * view.Scale : -100 * view.Scale;
                            double MoveY = moveUp ? 100 * view.Scale : -100 * view.Scale;
                            newcrop.Min = new XYZ(newcrop.Min.X + MoveX, newcrop.Min.Y+ MoveY, crop.Min.Z);
                            newcrop.Max = new XYZ(newcrop.Max.X + MoveX, newcrop.Max.Y +MoveY, crop.Max.Z);
                            view.CropBox = newcrop;
                            t.Commit();
                        }
                        BoundingBoxXYZ bb3 = viewport.get_BoundingBox(sheetview);

                        if (MoveRight) { pt1 = new XYZ(bb3.Min.X, pt1.Y, pt1.Z); }
                        else { pt2 = new XYZ(bb3.Max.X, pt2.Y, pt2.Z); }
                        double newY = bb3.Max.Y;
                        if (!moveUp &amp;amp;&amp;amp; !moveDown)  newY = pt1.Y;
                        if (moveUp) { newY = bb3.Min.Y; }
                        pt1 = new XYZ(pt1.X, newY, pt1.Z);
                        pt2 = new XYZ(pt2.X, newY, pt2.Z);
                    }
                    tg.RollBack();
                }
            return pt1.IsAlmostEqualTo(pt2)? null : Line.CreateBound(pt1,pt2);
            }
            catch (Exception ex)
            {
                TaskDialog.Show("catch", ex.ToString());
                return null;
            }
        }
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 23:21:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7028245#M59098</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-04-19T23:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: viewport position</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7153242#M59099</link>
      <description>&lt;P&gt;thx...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but then I get a Line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I apply back size and position of this line to &amp;nbsp;underline of the viewport?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 21:35:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7153242#M59099</guid>
      <dc:creator>sonicer</dc:creator>
      <dc:date>2017-06-14T21:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: viewport position</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7154280#M59100</link>
      <description>&lt;P&gt;The resulting Line is a "clone" of the ExtensionLine&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="Viewport.PNG" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/367576iF60AFC067D19C0EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Viewport.PNG" alt="Viewport.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 10:29:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7154280#M59100</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-06-15T10:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: viewport position</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7154876#M59101</link>
      <description>&lt;P&gt;thanks...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but still understand &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;first I disable annotation and underline of the viewport than I get boundingbox min max...then I duplicate this viewport. - work ok.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For add to duplicated sheet I used your code of the line extension.....the input paramter is the viewport from the original sheets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;code &lt;SPAN style="color: #004085;"&gt;Line&lt;/SPAN&gt;.&lt;SPAN style="color: #191970; font-weight: bold;"&gt;CreateBound&lt;/SPAN&gt;(pt1, pt2);&amp;nbsp; realy create extension line that is moved with viewport?&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="obrazek.png" style="width: 564px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/367665iE05CA9CBFAAF1E2C/image-size/large?v=v2&amp;amp;px=999" role="button" title="obrazek.png" alt="obrazek.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:22:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7154876#M59101</guid>
      <dc:creator>sonicer</dc:creator>
      <dc:date>2017-06-15T14:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: viewport position</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7155789#M59102</link>
      <description>&lt;P&gt;there is no API method available to get / set&amp;nbsp;the position of the ViewPort Title and ExtensionLine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far&amp;nbsp;as I know,&amp;nbsp;&amp;nbsp;what you want, can't be done.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 19:58:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/7155789#M59102</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-06-15T19:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: viewport position</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/9511157#M59103</link>
      <description>&lt;P&gt;Did you have any issues using this line?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;get_Parameter(BuiltInParameter.VIEWPORT_ATTR_LABEL_TAG).Set()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use mine for a different plugin but I get an error and I have to run it twice to have the viewtitle show up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/61641220/revit-api-c-sharp-how-to-set-view-title-on-viewport?noredirect=1&amp;amp;lq=1" target="_blank"&gt;https://stackoverflow.com/questions/61641220/revit-api-c-sharp-how-to-set-view-title-on-viewport?noredirect=1&amp;amp;lq=1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 21:16:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/viewport-position/m-p/9511157#M59103</guid>
      <dc:creator>Maltezc</dc:creator>
      <dc:date>2020-05-12T21:16:46Z</dc:date>
    </item>
  </channel>
</rss>

