关闭

用未公开的函数acedSetDynInputDisplayMessage来实现动态显示

标签: AutoCAD.netAutoCAD .NetDynamic Input
721人阅读 评论(0) 收藏 举报
分类:

原文见: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;

#endregion

namespace 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.Edit​or;
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());
}
}
}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:40909次
    • 积分:675
    • 等级:
    • 排名:千里之外
    • 原创:9篇
    • 转载:11篇
    • 译文:19篇
    • 评论:3条
    最新评论