.NET

.NET

Reply
New Member
zwq740414
Posts: 2
Registered: ‎07-11-2006
Message 1 of 3 (364 Views)

how to use acedSetCurrentView function?

364 Views, 2 Replies
07-11-2006 02:59 AM
hello
i want to Zoom or pan the current view(in modelSapce), and i find a function - acedSetCurrentView ,but it does not work,where error?

the program is :

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

namespace ClassLibrary2
{
public static class Class1
{
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "#500")]
private static extern bool acedVportTableRecords2Vports();

//[DllImport("acad.exe")]//, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="?acedVports2VportTableRecords@@YA?AW4ErrorStatus@Acad@@XZ")]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "#501")]
private static extern bool acedVports2VportTableRecords();

//[DllImport("acad.exe")]//, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="?acedSetCurrentView@@YA?AW4ErrorStatus@Acad@@PAVAcDbViewTableRecord@@PAVAcDbViewport@@@Z")> _
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "#444")]
private static extern int acedSetCurrentView(IntPtr viewTableRec, int viewport);

[CommandMethod("MyZoom")]
public static void MyZoom()
{
MyZoom(new Point2d(100, 100), 10, 10);
}
private static Autodesk.AutoCAD.Runtime.ErrorStatus MyZoom(Point2d CenterPt, double Height, double Width)
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();

ErrorStatus es;
ViewTableRecord view = new ViewTableRecord();
view.CenterPoint = CenterPt;
view.FrontClipAtEye = false;
view.Height = Height;
view.Width = Width;
es = (ErrorStatus)acedSetCurrentView(view.UnmanagedObject, 0);
try
{
HostApplicationServices.WorkingDatabase.UpdateExt(true);
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
MessageBox.Show(ex.Message);
}

ed.UpdateScreen();
docLock.Dispose();

return es;
}
}
}
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 2 of 3 (364 Views)

Re: how to use acedSetCurrentView function?

07-11-2006 09:15 AM in reply to: zwq740414
Look at this topic and I think you find solution:
http://www.theswamp.org/index.php?topic=10475.0
New Member
zwq740414
Posts: 2
Registered: ‎07-11-2006
Message 3 of 3 (364 Views)

Re: how to use acedSetCurrentView function?

07-11-2006 05:49 PM in reply to: zwq740414
Thank you very much!

I think i find a good site again,thinks!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.