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

how to use acedSetCurrentView function?

2 REPLIES 2
Reply
Message 1 of 3
zwq740414
755 Views, 2 Replies

how to use acedSetCurrentView function?

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;
}
}
}
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: zwq740414

Look at this topic and I think you find solution:
http://www.theswamp.org/index.php?topic=10475.0
Message 3 of 3
zwq740414
in reply to: zwq740414

Thank you very much!

I think i find a good site again,thinks!

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