<?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: Zoom Oddity I have seen in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7196432#M30766</link>
    <description>&lt;P&gt;These topics and code samples might be helpful:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Manipulate the Current View (.NET)&lt;BR /&gt;&lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-FAC1A5EB-2D9E-497B-8FD9-E11D2FF87B93" target="_self"&gt;http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-FAC1A5EB-2D9E-497B-8FD9-E11D2FF87B93&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Display Drawing Extents and Limits (.NET)&lt;BR /&gt;&lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-70B3140A-14F1-4F54-AF5F-8DEDB444C3BA" target="_self"&gt;http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-70B3140A-14F1-4F54-AF5F-8DEDB444C3BA&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jun 2017 22:07:16 GMT</pubDate>
    <dc:creator>ambrosl</dc:creator>
    <dc:date>2017-06-30T22:07:16Z</dc:date>
    <item>
      <title>Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7195915#M30763</link>
      <description>&lt;P&gt;I use ZoomExtents, ZoomWindow, ZoomEntity, pretty much as described&amp;nbsp;at:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://through-the-interface.typepad.com/through_the_interface/2008/06/zooming-to-a-wi.html" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2008/06/zooming-to-a-wi.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I will get the Database.Extmin and Database.Extmax for the extents to feed to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;		public static void ZoomWin(Editor acEd, Point3d min, Point3d max)
		{
			Point2d min2d = new Point2d(min.X, min.Y);
			Point2d max2d = new Point2d(max.X, max.Y);
			ViewTableRecord view = new ViewTableRecord();
			Point3d vcen = MidpointPtPt(min2d, max2d);
			view.CenterPoint = new Point2d(vcen.X, vcen.Y);
			//view.CenterPoint = min2d + ((max2d - min2d) / 2.0);
			view.Height = max2d.Y - min2d.Y;
			view.Width = max2d.X - min2d.X;
			acEd.Regen();
			acEd.SetCurrentView(view);
		}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I have found is that often, about every other time, it 'blacks out'.&amp;nbsp; I can then Set Next Statement back to the acEd.Regen(), then step on through and it will then show everything.&amp;nbsp; I have tried it with and without the Regen, but either way the results is the same.&lt;/P&gt;
&lt;P&gt;While it is annoying, it isn't major, but if someone has an answer, I would appreciate it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, I have tried other methods for the Zoom Extents, and actually get the same results, half or so of the time it blacks out.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 17:47:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7195915#M30763</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2017-06-30T17:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7196113#M30764</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a Zoom extents have you try calling Database.UpdateExt() before getting Database.Extmin and Database.Extmax?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What if using the COM Zoom methods:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dynamic acadApp = Application.AcadApplication;
acadApp.ZoomExtents();&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 18:59:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7196113#M30764</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-06-30T18:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7196129#M30765</link>
      <description>&lt;P&gt;Giles,&lt;/P&gt;
&lt;P&gt;I have tried the COM method as well, with same results.&amp;nbsp; Adding the acDb.UpdateExt(true) may have helped though.&amp;nbsp; I assume the true&amp;nbsp;for BestFit is correct.&amp;nbsp;It seems now it goes black fewer times.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 19:10:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7196129#M30765</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2017-06-30T19:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7196432#M30766</link>
      <description>&lt;P&gt;These topics and code samples might be helpful:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Manipulate the Current View (.NET)&lt;BR /&gt;&lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-FAC1A5EB-2D9E-497B-8FD9-E11D2FF87B93" target="_self"&gt;http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-FAC1A5EB-2D9E-497B-8FD9-E11D2FF87B93&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Display Drawing Extents and Limits (.NET)&lt;BR /&gt;&lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-70B3140A-14F1-4F54-AF5F-8DEDB444C3BA" target="_self"&gt;http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-70B3140A-14F1-4F54-AF5F-8DEDB444C3BA&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 22:07:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7196432#M30766</guid>
      <dc:creator>ambrosl</dc:creator>
      <dc:date>2017-06-30T22:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7197140#M30767</link>
      <description>&lt;P&gt;The extension methods I use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Autodesk.AutoCAD.EditorInput
{
    public static class ExtensionMethods
    {
        public static Matrix3d EyeToWorld(this ViewTableRecord view)
        {
            if (view == null)
                throw new ArgumentNullException("view");

            return
                Matrix3d.Rotation(-view.ViewTwist, view.ViewDirection, view.Target) *
                Matrix3d.Displacement(view.Target - Point3d.Origin) *
                Matrix3d.PlaneToWorld(view.ViewDirection);
        }

        public static Matrix3d WorldToEye(this ViewTableRecord view)
        {
            return view.EyeToWorld().Inverse();
        }

        public static void Zoom(this Editor ed, Extents3d ext)
        {
            if (ed == null)
                throw new ArgumentNullException("ed");

            using (ViewTableRecord view = ed.GetCurrentView())
            {
                ext.TransformBy(view.WorldToEye());
                view.Width = ext.MaxPoint.X - ext.MinPoint.X;
                view.Height = ext.MaxPoint.Y - ext.MinPoint.Y;
                view.CenterPoint = new Point2d(
                    (ext.MaxPoint.X + ext.MinPoint.X) / 2.0,
                    (ext.MaxPoint.Y + ext.MinPoint.Y) / 2.0);
                ed.SetCurrentView(view);
            }
        }

        public static void ZoomCenter(this Editor ed, Point3d center, double scale = 1.0)
        {
            if (ed == null)
                throw new ArgumentNullException("ed");

            using (ViewTableRecord view = ed.GetCurrentView())
            {
                center = center.TransformBy(view.WorldToEye());
                view.Height /= scale;
                view.Width /= scale;
                view.CenterPoint = new Point2d(center.X, center.Y);
                ed.SetCurrentView(view);
            }
        }

        public static void ZoomExtents(this Editor ed)
        {
            if (ed == null)
                throw new ArgumentNullException("ed");

            Database db = ed.Document.Database;
            db.UpdateExt(false);
            Extents3d ext = (short)Application.GetSystemVariable("cvport") == 1 ?
                new Extents3d(db.Pextmin, db.Pextmax) :
                new Extents3d(db.Extmin, db.Extmax);
            ed.Zoom(ext);
        }

        public static void ZoomObjects(this Editor ed, IEnumerable&amp;lt;ObjectId&amp;gt; ids)
        {
            if (ed == null)
                throw new ArgumentNullException("ed");

            using (Transaction tr = ed.Document.TransactionManager.StartTransaction())
            {
                Extents3d ext = ids
                    .Where(id =&amp;gt; id.ObjectClass.IsDerivedFrom(RXObject.GetClass(typeof(Entity))))
                    .Select(id =&amp;gt; ((Entity)tr.GetObject(id, OpenMode.ForRead)).GeometricExtents)
                    .Aggregate((e1, e2) =&amp;gt; { e1.AddExtents(e2); return e1; });
                ed.Zoom(ext);
                tr.Commit();
            }
        }

        public static void ZoomScale(this Editor ed, double scale)
        {
            if (ed == null)
                throw new ArgumentNullException("ed");

            using (ViewTableRecord view = ed.GetCurrentView())
            {
                view.Width /= scale;
                view.Height /= scale;
                ed.SetCurrentView(view);
            }
        }

        public static void ZoomWindow(this Editor ed, Point3d p1, Point3d p2)
        {
            using (Line line = new Line(p1, p2))
            {
                ed.Zoom(line.GeometricExtents);
            }
        }
    }
}&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jul 2017 06:24:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7197140#M30767</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-07-01T06:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7200248#M30768</link>
      <description>&lt;P&gt;Lee,&amp;nbsp;above, the code Gilles posted seems to be the same gist of the link you gave.&amp;nbsp; With the exceptions that the link uses a Line for some calcs and Gilles' code is an Extension.&amp;nbsp; Unless I am missing something...&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 12:12:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7200248#M30768</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2017-07-03T12:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7200284#M30769</link>
      <description>&lt;P&gt;Gilles, I would have thought the database.UpdateExt() would have been true rather than false?&amp;nbsp; I appreciate seeing it done as an extension.&amp;nbsp; I discovered this technique a couple of months ago, and have been trying to build on that technique.&amp;nbsp; I had not thought of making the zooms into extensions. Kudos.&lt;/P&gt;
&lt;P&gt;After a few test runs, it does seem to be updating more often now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are still some oddities in my scenario, I Insert a block, then copy that block several times.&amp;nbsp; The view update doesn't occur following the Insert, does update after the first copy, misses the second copy, does update after the third, and so on, continues update after 'every other' copy.&lt;/P&gt;
&lt;P&gt;Very weird...&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 12:30:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7200284#M30769</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2017-07-03T12:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7200430#M30770</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;dennis a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;Gilles, I would have thought the database.UpdateExt() would have been true rather than false?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;From the docs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;FONT color="#333399"&gt;Setting the argument &lt;FONT face="courier new,courier"&gt;doBestFit&lt;/FONT&gt; to TRUE means that while traversing the database, any &lt;FONT face="courier new,courier"&gt;BlockReference&lt;/FONT&gt; entities found should have their &lt;FONT face="courier new,courier"&gt;geomExtentsBestFit()&lt;/FONT&gt; method called instead of &lt;FONT face="courier new,courier"&gt;geomExtents()&lt;/FONT&gt;. This will be slower but will generate a tighter bounding box (extents). Using the default argument of FALSE will be faster but may not produce the tightest bounding box.&lt;/FONT&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 13:23:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7200430#M30770</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-07-03T13:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Oddity I have seen</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7200615#M30771</link>
      <description>&lt;P&gt;Kudos Gilles.&lt;/P&gt;
&lt;P&gt;I have resolved the problem.&amp;nbsp; By doing a little zooming manipulation.&amp;nbsp; Experimenting around, I found that if I ZoomObjects on the cloned blk, then follow that with the ZoomExtents, I see the series Insert, then Clone as many times as I need.&amp;nbsp; Your code made me learn a little too, specifically with the IEnumerable and, as well, I did not know I could reach the Database via the Editor (Editor.Document.Database).&amp;nbsp; Both have me now, looking through my existing code to see where I could utilize these two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 14:39:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-oddity-i-have-seen/m-p/7200615#M30771</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2017-07-03T14:39:52Z</dc:date>
    </item>
  </channel>
</rss>

