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;
}
}
}