本文主要是介绍用未公开的函数acedSetDynInputDisplayMessage来实现动态显示,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
原文见:http://forums.autodesk.com/t5/NET/Dynamic-Input/td-p/1339772
目前AutoCAD未公开实现Dynamic Input的API,要实现和AutoCAD同样的效果,可以使用一个未公开的函数acedSetDynInputDisplayMessage
以下是C#代码:
using System;
using System.Text;using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;using System.Threading;
using System.Globalization;
using System.Runtime.InteropServices;#endregionnamespace RSNNAcadApp.Test
{
public class Test
{
//this is an undocumented api exported from acad.exe. Use it at your
own risk.
//
// Setting this flag tells AutoCAD to display the last string output
to the command line
//in the Dynamic Input prompt window (one time only.)
[DllImport("acad.exe",
EntryPoint="?acedSetDynInputDisplayMessage@@YA_N_N@Z")]
private static extern bool acedSetDynInputDisplayMessage(bool
displayMessageOnce);private double m_dist; //last distance chosen (per-document)
private bool m_firstTime = true; //first invocation of "test"?
(per-document)
//use a non-static command method so the enclosing class (Test) will
be instantiated
//for each document
[CommandMethod("test")]
public void DoIt()
{
Editor ed =
Application.DocumentManager.MdiActiveDocument.Editor;
PromptDistanceOptions opt1 = new PromptDistanceOptions("Abstand
zeigen");opt1.AllowNegative = false;
opt1.AllowZero = false;
opt1.AllowNone = false;
opt1.UseDashedLine = true;
if (!m_firstTime)
opt1.DefaultValue = m_dist;PromptDoubleResult res = ed.GetDistance(opt1);if (res.Status == PromptStatus.OK)
{
m_dist = res.Value;
ed.WriteMessage(String.Format("Abstand = {0}",
m_dist.ToString()));
acedSetDynInputDisplayMessage(true);
}
m_firstTime = false;
}
void MyPointFilter(object sender, PointFilterEventArgs e)
{
e.Result.ToolTipText = String.Format("Abstand = {0}",
m_dist.ToString());
}
}
}
这篇关于用未公开的函数acedSetDynInputDisplayMessage来实现动态显示的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!