<?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: i want to create a viewport in a layout, but the code generate a importdll e in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872544#M45130</link>
    <description>&lt;P&gt;Will send mods a message that swaywood is trying join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you use swaywood as user name?&lt;/P&gt;</description>
    <pubDate>Sat, 08 Mar 2014 07:20:10 GMT</pubDate>
    <dc:creator>jeff</dc:creator>
    <dc:date>2014-03-08T07:20:10Z</dc:date>
    <item>
      <title>i want to create a viewport in a layout, but the code generate a importdll error</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872310#M45124</link>
      <description>&lt;P&gt;i want to create a viewport in a layout, and i get some code from kean's blog, but the code generate a importdll error, please help me!&lt;/P&gt;&lt;P&gt;the system is Win7x64bit+AutoCAD2013&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using System;&lt;BR /&gt;using System.Collections.Generic;&lt;BR /&gt;using System.Linq;&lt;BR /&gt;using System.Text;&lt;BR /&gt;using System.Runtime.InteropServices;&lt;BR /&gt;using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;using Autodesk.AutoCAD.ApplicationServices;&lt;BR /&gt;using Autodesk.AutoCAD.DatabaseServices;&lt;BR /&gt;using Autodesk.AutoCAD.Geometry;&lt;BR /&gt;using Autodesk.AutoCAD.EditorInput;&lt;BR /&gt;using AcGi = Autodesk.AutoCAD.GraphicsInterface;&lt;/P&gt;&lt;P&gt;namespace sample&lt;BR /&gt;{&lt;BR /&gt;public class paperViewport&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;EntryPoint = "?acedSetCurrentVPort@@YA?AW4ErrorStatus@Acad@@PBVAcDbViewport@@@Z")]&lt;/FONT&gt;&lt;BR /&gt;extern static private int acedSetCurrentVPort(IntPtr AcDbVport);&lt;/P&gt;&lt;P&gt;[CommandMethod("CreateFloatingViewport")]&lt;BR /&gt;public static void CreateFloatingViewport()&lt;BR /&gt;{&lt;BR /&gt;// Get the current document and database, and start a transaction&lt;BR /&gt;Document acDoc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;Database acCurDb = acDoc.Database;&lt;/P&gt;&lt;P&gt;using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;// Open the Block table for read&lt;BR /&gt;BlockTable acBlkTbl;&lt;BR /&gt;acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,&lt;BR /&gt;OpenMode.ForRead) as BlockTable;&lt;/P&gt;&lt;P&gt;// Open the Block table record Paper space for write&lt;BR /&gt;BlockTableRecord acBlkTblRec;&lt;BR /&gt;acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.PaperSpace],&lt;BR /&gt;OpenMode.ForWrite) as BlockTableRecord;&lt;/P&gt;&lt;P&gt;// Switch to the previous Paper space layout&lt;BR /&gt;Application.SetSystemVariable("TILEMODE", 0);&lt;BR /&gt;acDoc.Editor.SwitchToPaperSpace();&lt;/P&gt;&lt;P&gt;// Create a Viewport&lt;BR /&gt;Viewport acVport = new Viewport();&lt;BR /&gt;acVport.CenterPoint = new Point3d(3.25, 3, 0);&lt;BR /&gt;acVport.Width = 6;&lt;BR /&gt;acVport.Height = 5;&lt;/P&gt;&lt;P&gt;// Add the new object to the block table record and the transaction&lt;BR /&gt;acBlkTblRec.AppendEntity(acVport);&lt;BR /&gt;acTrans.AddNewlyCreatedDBObject(acVport, true);&lt;/P&gt;&lt;P&gt;// Change the view direction&lt;BR /&gt;acVport.ViewDirection = new Vector3d(1, 1, 1);&lt;/P&gt;&lt;P&gt;// Enable the viewport&lt;BR /&gt;acVport.On = true;&lt;/P&gt;&lt;P&gt;// Activate model space in the viewport&lt;BR /&gt;acDoc.Editor.SwitchToModelSpace();&lt;/P&gt;&lt;P&gt;// Set the new viewport current via an imported ObjectARX function&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;//error message:Unable to find an entry point named '?' in DLL 'acad.exe'.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;acedSetCurrentVPort(acVport.UnmanagedObject);&lt;/P&gt;&lt;P&gt;// Save the new objects to the database&lt;BR /&gt;acTrans.Commit();&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2014 02:40:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872310#M45124</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2014-03-08T02:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872344#M45125</link>
      <description>&lt;P&gt;Need to use exported names from 2013 and that function moved from acad.exe&amp;nbsp;to accore.dll in 2013&lt;/P&gt;&lt;P&gt;Link for getting exported names&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.theswamp.org/index.php?topic=41527.msg499429#msg499429" target="_blank"&gt;http://www.theswamp.org/index.php?topic=41527.msg499429#msg499429&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And when need to change values to ones in red below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[DllImport("&lt;FONT color="#ff0000"&gt;accore.dll&lt;/FONT&gt;", CallingConvention = CallingConvention.Cdecl,&lt;BR /&gt;&lt;FONT color="#888888"&gt;EntryPoint = "&lt;FONT color="#ff0000"&gt;?acedSetCurrentVPort@@YA?AW4ErrorStatus@Acad@@PEBVAcDbViewport@@@Z&lt;/FONT&gt;")]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2014 03:49:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872344#M45125</guid>
      <dc:creator>jeff</dc:creator>
      <dc:date>2014-03-08T03:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872436#M45127</link>
      <description>thanks a lot jeff. but how did you know this? and where are you learn from this knowlage point?</description>
      <pubDate>Sat, 08 Mar 2014 06:00:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872436#M45127</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2014-03-08T06:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872478#M45128</link>
      <description>&lt;P&gt;Just google "name mangling" or "name decoration"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also extern and __declspec for not being managled.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2014 06:24:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872478#M45128</guid>
      <dc:creator>jeff</dc:creator>
      <dc:date>2014-03-08T06:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872536#M45129</link>
      <description>&lt;P&gt;i registed yesterday but still not approved by&amp;nbsp;&lt;SPAN&gt;TheSwamp.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2014 07:16:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872536#M45129</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2014-03-08T07:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872544#M45130</link>
      <description>&lt;P&gt;Will send mods a message that swaywood is trying join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you use swaywood as user name?&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2014 07:20:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872544#M45130</guid>
      <dc:creator>jeff</dc:creator>
      <dc:date>2014-03-08T07:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872562#M45131</link>
      <description>yes&lt;BR /&gt;it is swaywood&lt;BR /&gt;thanks</description>
      <pubDate>Sat, 08 Mar 2014 07:29:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872562#M45131</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2014-03-08T07:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872594#M45132</link>
      <description>&lt;P&gt;I have no luck with this code snippet on my A2014&lt;/P&gt;
&lt;P&gt;but the follwing code does the job&lt;/P&gt;
&lt;P&gt;Command only works in paperspace!&lt;/P&gt;
&lt;PRE&gt;   

        //	&lt;A href="http://adndevblog.typepad.com/autocad/2012/08/create-paper-space-viewports.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/08/create-paper-space-viewports.html&lt;/A&gt;
        [CommandMethod("VW")]
        public void tryCreateViewPort()
        {
            // Only works in paperspace
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            
            try
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                   // ed.SwitchToPaperSpace();
                    ObjectId mCurViewportId = ed.ActiveViewportId;

                    if (mCurViewportId == ObjectId.Null)
                    {
                        ed.WriteMessage("\nCommand only works in paperspace.");

                        return;

                    }

                    Viewport pCurViewport = tr.GetObject(mCurViewportId, OpenMode.ForRead) as Viewport;

                    if (pCurViewport == null)
                    {

                        ed.WriteMessage("\nCannot get active viewport.");

                        return;

                    }

                    if (pCurViewport.Number != 1)
                    {

                        ed.WriteMessage("\nCommand only works in paperspace.");

                        return;

                    }

                    // Ask for the position

                    Point3d pt1; Point3d pt2;

                    pt1 = ed.GetPoint("\nSelect first corner: ").Value;

                    pt2 = ed.GetCorner("\nSelect second corner: ", pt1).Value;

                    // Ask for the view to use

                    string mViewName;

                    mViewName = ed.GetString("\nEnter name of view to use: ").StringResult;

                    // Create new viewport

                    Viewport pViewport = new Viewport();

                    pViewport.Width = Math.Abs(pt2.X - pt1.X);

                    pViewport.Height = Math.Abs(pt2.Y - pt1.Y);

                    pViewport.CenterPoint = new Point3d(

                      pt1.X + (pt2.X - pt1.X) / 2,

                      pt1.Y + (pt2.Y - pt1.Y) / 2,

                      pt1.Z);

                    // Append new viewport to paper space

                    BlockTable pTable;

                    BlockTableRecord pPsBTR;

                    pTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                    pPsBTR = (BlockTableRecord)tr.GetObject(pTable[BlockTableRecord.PaperSpace], OpenMode.ForWrite);

                    ObjectId mViewPortId = pPsBTR.AppendEntity(pViewport);

                    tr.AddNewlyCreatedDBObject(pViewport, true);
                    pViewport.On = true;
                    pViewport.FastZoomOn = true;

                    pViewport.SetUcs(pViewport.CenterPoint, Vector3d.XAxis, Vector3d.YAxis);


                    // Set the view



                    ViewTable pViewTable = (ViewTable)tr.GetObject(db.ViewTableId, OpenMode.ForRead);

                    // initialize the layout

                    // Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("TILEMODE", 0);
                    //  Layout layout = tr.GetObject(pPsBTR.LayoutId, OpenMode.ForWrite) as Layout;
                    //  LayoutManager.Current.CurrentLayout = "Layout2";
                    // layout.Initialize();

                    ViewTableRecord pViewTR;
                    if (pViewTable.Has(mViewName))
                    {
                        pViewTR = (ViewTableRecord)tr.GetObject(pViewTable[mViewName], OpenMode.ForWrite);
                    }
                    else
                    {
                        pViewTR = new ViewTableRecord();
                        pViewTR.Name = mViewName;
                        pViewTR.IsPaperspaceView = true;
                        pViewTable.UpgradeOpen();
                        ObjectId vtId = pViewTable.Add(pViewTR);

                        tr.AddNewlyCreatedDBObject(pViewTR, true);
                    }


                    ed.SetCurrentView(pViewTR);

                    tr.Commit();

                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("TILEMODE", 0);
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                ed.WriteMessage(ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
            }
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2014 07:43:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872594#M45132</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2014-03-08T07:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872676#M45133</link>
      <description>Also read articles &lt;BR /&gt;       &lt;A href="http://adndevblog.typepad.com/autocad/2012/04/the-property-viewviewport-is-not-available-any-more-in-autocad-net-2013-api.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/04/the-property-viewviewport-is-not-available-any-more-in-autocad-net-2013-api.html&lt;/A&gt;&lt;BR /&gt;        &lt;A href="http://adndevblog.typepad.com/autocad/2012/10/zooming-to-drawing-extents-for-a-viewport-without-sending-commands.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/10/zooming-to-drawing-extents-for-a-viewport-without-sending-commands.html&lt;/A&gt;</description>
      <pubDate>Sat, 08 Mar 2014 08:30:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872676#M45133</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2014-03-08T08:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: i want to create a viewport in a layout, but the code generate a importdll e</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872978#M45134</link>
      <description>&lt;P&gt;Hi Hallex:&lt;/P&gt;&lt;P&gt;thanks a lot, u r so&amp;nbsp;&lt;SPAN&gt;warmhearted.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2014 13:17:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-create-a-viewport-in-a-layout-but-the-code-generate-a/m-p/4872978#M45134</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2014-03-08T13:17:50Z</dc:date>
    </item>
  </channel>
</rss>

