.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set Current Paperspace Viewport - AutoCAD 2011 x64

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
AlexFielder
2463 Views, 6 Replies

Set Current Paperspace Viewport - AutoCAD 2011 x64

I've been using my own implementation of the "Create and enable a floating Viewport" from the AutoCAD 2011 Developer's Guide here, and everything works fine on a 32 bit system, but on 2 different Windows 7 64-bit systems, the following line results in a error:

 

 

//The reason I point this to the specific .exe file is because I have several versions of AutoCAD installed, and I wasn't sure how it knew which one to import the command from.[DllImport("c:\\Program Files\\Autodesk\\AutoCAD 2011\\acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedSetCurrentVPort@@YA?AW4ErrorStatus@Acad@@PBVAcDbViewport@@@Z")]
extern static private int acedSetCurrentVPort(IntPtr AcDbVport);

 

 

The error I receive is: 

 

 

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.EntryPointNotFoundException: Unable to find an entry point named '?' in DLL 'c:\Program Files\Autodesk\AutoCAD 2011\acad.exe'.
   at Autodesk.AutoCAD.CreateLayouts.MyCommands.acedSetCurrentVPort(IntPtr AcDbVport)
   at Autodesk.AutoCAD.CreateLayouts.LayoutCommands.AddNewVports(String LayoutName, ObjectId BlockId, List`1 newvport) in F:\My Documents\Visual Studio 2010\Projects\CreateLayouts\CreateLayouts\myCommands.cs:line 2723
   at Autodesk.AutoCAD.CreateLayouts.LayoutCommands.CreateNewLayouts(List`1 jobdetail, ObjectId BlockId, List`1 newvport) in F:\My Documents\Visual Studio 2010\Projects\CreateLayouts\CreateLayouts\myCommands.cs:line 2840
   at Autodesk.AutoCAD.CreateLayouts.MyCommands.BeginCreateLayouts(Dictionary`2 kpdict) in F:\My Documents\Visual Studio 2010\Projects\CreateLayouts\CreateLayouts\myCommands.cs:line 549
   at Autodesk.AutoCAD.CreateLayouts.MyCommands.CreateLayouts() in F:\My Documents\Visual Studio 2010\Projects\CreateLayouts\CreateLayouts\myCommands.cs:line 262
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4952 (win7RTMGDR.050727-4900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
acdbmgd
    Assembly Version: 18.1.0.0
    Win32 Version: 18.1.115.0.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/AcdbMgd.DLL
----------------------------------------
msvcm90
    Assembly Version: 9.0.30729.4926
    Win32 Version: 9.00.30729.4926
    CodeBase: file:///C:/Windows/WinSxS/amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_08e1a05ba83fe554/msvcm90.dll
----------------------------------------
PresentationFramework
    Assembly Version: 3.0.0.0
    Win32 Version: 3.0.6920.5001 built by: Win7RTMGDR
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/PresentationFramework/3.0.0.0__31bf3856ad364e35/PresentationFramework.dll
----------------------------------------
WindowsBase
    Assembly Version: 3.0.0.0
    Win32 Version: 3.0.6920.5001 built by: Win7RTMGDR
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/WindowsBase/3.0.0.0__31bf3856ad364e35/WindowsBase.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
PresentationCore
    Assembly Version: 3.0.0.0
    Win32 Version: 3.0.6920.5001 built by: Win7RTMGDR
    CodeBase: file:///C:/Windows/assembly/GAC_64/PresentationCore/3.0.0.0__31bf3856ad364e35/PresentationCore.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
AdApplicationFrame
    Assembly Version: 0.0.0.0
    Win32 Version: 3.0.269.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/AdApplicationFrame.DLL
----------------------------------------
AdWindows
    Assembly Version: 3.0.263.0
    Win32 Version: 3.0.263.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/AdWindows.DLL
----------------------------------------
PresentationFramework.Aero
    Assembly Version: 3.0.0.0
    Win32 Version: 3.0.6920.4902 built by: NetFXw7
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/PresentationFramework.Aero/3.0.0.0__31bf3856ad364e35/PresentationFramework.Aero.dll
----------------------------------------
acmgd
    Assembly Version: 18.1.0.0
    Win32 Version: 18.1.115.0.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/acmgd.DLL
----------------------------------------
AcWindows
    Assembly Version: 18.1.0.0
    Win32 Version: 18.1.115.0.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/AcWindows.DLL
----------------------------------------
System.Core
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.4926 built by: NetFXw7
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
AcWindows.resources
    Assembly Version: 18.1.0.0
    Win32 Version: 18.1.49.0.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/en-US/AcWindows.resources.DLL
----------------------------------------
AcCui
    Assembly Version: 18.1.0.0
    Win32 Version: 18.1.115.0.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/AcCui.DLL
----------------------------------------
ContextualTabSelectorRules
    Assembly Version: 0.0.0.0
    Win32 Version: 18.1.115.0.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/AcWindows.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
ManagedMC3
    Assembly Version: 4.11.0.0
    Win32 Version: 4.12.0.0
    CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202011/ManagedMC3.DLL
----------------------------------------
UIAutomationProvider
    Assembly Version: 3.0.0.0
    Win32 Version: 3.0.6920.4902 built by: NetFXw7
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/UIAutomationProvider/3.0.0.0__31bf3856ad364e35/UIAutomationProvider.dll
----------------------------------------
CreateLayouts
    Assembly Version: 1.0.3989.31668
    Win32 Version: 1.0.0.0
    CodeBase: file:///F:/My%20Documents/Visual%20Studio%202010/Projects/CreateLayouts/CreateLayouts/bin/debug/CreateLayouts.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

I guess there must be something I'm missing - the application I'm building works just fine on 32 bit AutoCAD Civil 3D 2009, yet on 64 bit AutoCAD 2011 it fails every time.

 

6 REPLIES 6
Message 2 of 7
AlexFielder
in reply to: AlexFielder

I think I might have just fixed this issue myself. After googling the exact error message:

 

"Unable to find an entry point named '?' in DLL"

 

I ended up here: 

 

http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/a96468dc-9426-404e-ace7-0f7a1c8b4...

 

This then pointed me to http://www.dependencywalker.com/

 

After downloading and running this tool on acad.exe I found the function I was looking for.

 

In the attached image you'll see what the correct external call should be.

 

tl;dr: use this:

 

?acedSetCurrentVPort@@YA?AW4ErrorStatus@Acad@@PEBVAcDbViewport@@@Z

 

instead of this: 

?acedSetCurrentVPort@@YA?AW4ErrorStatus@Acad@@PBVAcDbViewport@@@Z

I'm not sure if this affects the 32 bit version of AutoCAD 2011, as I don't have it installed anywhere.

Message 3 of 7
boberthinton
in reply to: AlexFielder

Your solution is 7 years old now, so I was wondering if this is still the only method of setting the current paperspace viewport? If not is there a way to find the location of accore.dll for the version of autocad being used?

Message 4 of 7
_gile
in reply to: boberthinton

Hi,

 

What about using the CVPORT sysvar?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 7
_gile
in reply to: _gile

// Set the new viewport current via an imported ObjectARX function the CVPORT system variable
Application.SetSystemVariable("CVPORT", viewport.Number);

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 7
boberthinton
in reply to: AlexFielder

In my case, all I've got is viewport objectid. I don't think I can obtain the viewport number from the viewport object. It my exist in the layout object, but I think those numbers are assigned when the layout is open.
Message 7 of 7
_gile
in reply to: boberthinton


buttcrackbob a écrit :
In my case, all I've got is viewport objectid. I don't think I can obtain the viewport number from the viewport object. It my exist in the layout object, but I think those numbers are assigned when the layout is open.

It seems to me the layout have to be opened to set current one of its viewport...



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost