<?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: eNotAplicable error in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3926765#M49545</link>
    <description>&lt;P&gt;Thanks for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;PRE&gt;    Public Sub OFFVIEWPORT()
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Dim lays As DBDictionary = acTrans.GetObject(acCurDb.LayoutDictionaryId, OpenMode.ForRead)
            For Each item As DBDictionaryEntry In lays
                If item.Key &amp;lt;&amp;gt; "Model" Then
                    Dim lay As Layout = TryCast(acTrans.GetObject(item.Value, OpenMode.ForRead, False, True), Layout)
                    For Each vpid As ObjectId In lay.GetViewports()
                        Dim vp As Autodesk.AutoCAD.DatabaseServices.Viewport = TryCast(acTrans.GetObject(vpid, OpenMode.ForWrite, True, True), Autodesk.AutoCAD.DatabaseServices.Viewport)

                        vp.On = False 'Error
                       'vp.on=true 'is OK
                    Next
                End If
            Next
            acTrans.Commit()
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2013 16:57:34 GMT</pubDate>
    <dc:creator>ditran7577</dc:creator>
    <dc:date>2013-05-17T16:57:34Z</dc:date>
    <item>
      <title>eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3926338#M49543</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I met error "eNotAplicable" when&amp;nbsp;I try to turn off object in viewports each. What happen?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 10:08:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3926338#M49543</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-05-17T10:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3926742#M49544</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1128366"&gt;@ditran7577&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I met error "eNotAplicable" when&amp;nbsp;I try to turn off object in viewports each. What happen?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How you try to turn off object in viewports? Please provide your's code.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 16:31:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3926742#M49544</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-05-17T16:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3926765#M49545</link>
      <description>&lt;P&gt;Thanks for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;PRE&gt;    Public Sub OFFVIEWPORT()
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Dim lays As DBDictionary = acTrans.GetObject(acCurDb.LayoutDictionaryId, OpenMode.ForRead)
            For Each item As DBDictionaryEntry In lays
                If item.Key &amp;lt;&amp;gt; "Model" Then
                    Dim lay As Layout = TryCast(acTrans.GetObject(item.Value, OpenMode.ForRead, False, True), Layout)
                    For Each vpid As ObjectId In lay.GetViewports()
                        Dim vp As Autodesk.AutoCAD.DatabaseServices.Viewport = TryCast(acTrans.GetObject(vpid, OpenMode.ForWrite, True, True), Autodesk.AutoCAD.DatabaseServices.Viewport)

                        vp.On = False 'Error
                       'vp.on=true 'is OK
                    Next
                End If
            Next
            acTrans.Commit()
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 16:57:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3926765#M49545</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-05-17T16:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3927025#M49546</link>
      <description>&lt;P&gt;You may want to&amp;nbsp;try the code like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each vpid As ObjectId In lay.GetViewports()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim vp As Autodesk.AutoCAD.DatabaseServices.Viewport = TryCast&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''you cannot turn off viewport the layout itself is shown in it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If vp.Number&amp;lt;&amp;gt;1 Then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vp.On=False&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 21:08:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3927025#M49546</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2013-05-17T21:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3927605#M49547</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the code but it did not solve the proplem. &lt;SPAN&gt;An error occurred while processing your &lt;/SPAN&gt;guidance. At "Model space" error is: "eNotAplicable" or at "layout" error is "Autocad application has stopped working".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2013 12:02:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3927605#M49547</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-05-18T12:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3927628#M49548</link>
      <description>&lt;P&gt;Well, I forgot to mention that if the layout is not active, all viewport's Number property would be -1 and you cannot turn it on or off. So, you need to set each layout as current before turn viewport on the layout on/off. Here is sample code that toggle viewports on one or more layouts on or off:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public class MyCommands 
{
    private static bool _vpOn = true;

    [CommandMethod("ToggleVP")]
    public static void RunToggleViewport()
    {
        _vpOn = !_vpOn;
        ToggleViewport(_vpOn);
    }

    private static void ToggleViewport(bool vpOn)
    {
        Document dwg = Application.DocumentManager.MdiActiveDocument;
        Editor ed = dwg.Editor;
        Database db = dwg.Database;

        LayoutManager lManager = LayoutManager.Current;
        string curLayout = lManager.CurrentLayout;

        try
        {
            using (Transaction tran = db.TransactionManager.StartTransaction())
            {
                DBDictionary layDic = (DBDictionary)tran.GetObject(db.LayoutDictionaryId, OpenMode.ForRead);
                foreach (DBDictionaryEntry entry in layDic)
                {
                    if (entry.Key.ToUpper() != "MODEL")
                    {
                        Layout layout = (Layout)tran.GetObject(entry.Value, OpenMode.ForRead);
                        lManager.CurrentLayout = layout.LayoutName;
                        ed.WriteMessage("\nLayout: {0}", layout.LayoutName);

                        ObjectIdCollection vpIds = layout.GetViewports();
                        foreach (ObjectId id in vpIds)
                        {
                            Viewport vp = (Viewport)tran.GetObject(id, OpenMode.ForRead);
                            ed.WriteMessage("\n =&amp;gt;Viewport number: {0}", vp.Number);
                            if (vp.Number != 1)
                            {
                                vp.UpgradeOpen();
                                vp.On = vpOn;
                            }
                        }
                    }
                }

                tran.Commit();
            }
        }
        finally
        {
            if (lManager.CurrentLayout != curLayout)
            {
                lManager.CurrentLayout = curLayout;
            }
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2013 13:15:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3927628#M49548</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2013-05-18T13:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3928189#M49550</link>
      <description>&lt;P&gt;Thanks for help,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's work but the progress is too slow.&amp;nbsp;&lt;SPAN&gt;It's takes some minutes to turn off all viewports of about 10 layouts. I think because Acad regen after switch layout each. Please give me a suggestion.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2013 07:30:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3928189#M49550</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-05-20T07:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3930237#M49551</link>
      <description>&lt;P&gt;You may play around with "Layout Regen Options" ("Options" dialog box, tab "System"). Try select&amp;nbsp;different radio button to&amp;nbsp;run the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 3 radion buttons are corresponding to the 3 values of system variable "&amp;nbsp;LAYOUTREGENCTL" (0, 1, and 2). With the best result of your try, you can then set the system variable to the desired value before runnong your code to toggle viewports on layouts on and off, and then set the system variable back at the end of your code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2013 13:33:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3930237#M49551</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2013-05-21T13:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3930430#M49552</link>
      <description>&lt;P&gt;Can you help me the code?&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2013 15:14:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3930430#M49552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-05-21T15:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3930884#M49553</link>
      <description>&lt;P&gt;What code you need help? Do you mean how to set system variable "LAYOUTREGNCTL"? Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Save current value of the system variable&lt;/P&gt;&lt;P&gt;object&amp;nbsp;oldValue=Application.GetSysVariable("LAYOUTREGENCTL");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Set the system's variable to 0, 1, or 2, whichever is the best for the following operation&lt;/P&gt;&lt;P&gt;Application.SetSysVariable("LAYOUTREGENCTL", 0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Turn on/off viewport on layout, as discussed in previous posts&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Afterward, restore the system variable back to its original value&lt;/P&gt;&lt;P&gt;Application.SetSysVariable("LAYOUTREGENCTL", oldValue);&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2013 21:33:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3930884#M49553</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2013-05-21T21:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: eNotAplicable error</title>
      <link>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3931105#M49556</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks for help. The process is not faster. I don'n know what happen?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there any way to turn off viewport each that we do not set&amp;nbsp;&lt;SPAN&gt;the current layout to active layout?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2013 04:28:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/enotaplicable-error/m-p/3931105#M49556</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2013-05-22T04:28:50Z</dc:date>
    </item>
  </channel>
</rss>

