nobody 发表于 2015-8-11 22:59:51

尝试显示瞬态文本

试图暂时显示文本...需要一些帮助s,需要知道为什么这不会总是清除文本以及想知道如何让文本显示在我的屏幕中心,我尝试获取屏幕点的平均值,但似乎不起作用,所以我现在只是将位置设置在一个临时位置。公共静态DBObjectCollection temtext=new DBObjectCollection();。
公共静态intColl=new intgerCollection();。
公共静态无效DisplayText(string mystring)。
{。
文档acDoc=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;。
编辑我的编辑器=Application.DocumentManager.MdiActiveDocument.Editor;。
Point2d屏幕大小=(Point2d)Application.GetSystemVariable("SCREENSIZE");。
System.Drawing.Point新System.Drawing.Point。
System.Drawing.Pointlowerright=新的System.Drawing.Point((int)屏幕尺寸. X,(int)屏幕尺寸. Y);。
Point3d upperLeftWorld=MyEditor.PointToWorld(upper↓,0);。
Point3d lowerRightWorld=MyEditor.PointToWorld(lowerright,0);。
双屏幕大小=upperLeftWorld.DistanceTo(lowerRightWorld);。
acDoc.CommandWillStart+=新的命令事件处理程序(doc_CommandWillStart);。
DBText mytext=new DBText();。
mytext.TextString=mystring;。
mytext.Height=屏幕大小*.02;。
mytext.Position=新的Point3d(lowerRightWorld. X-20, lowerRightWorld. Y+20,0);。
mytext.ColorIndex=140;。
aGi.TransientManager.CurrentTransientManager.AddTransient(mytext,aGi.TransientDrawingMode.DirectTopmost,128, intColl);。
temptext.Add(mytext);。
}。
公共静态无效doc_CommandWillStart(对象发送者,命令EventArgs e)。
{。
如果(e.GlobalCommandName.Contains("REGEN"))。
{。
ClearMarkers();。
文档文档=Application.DocumentManager.MdiActiveDocument;。
doc.CommandWillStart-=新的命令事件处理程序(doc_CommandWillStart);。
}。
}。
公共静态空ClearMarkers()。
{。
aGi.TransientManager.CurrentTransientManager.EraseTransient(temtext, intColl);。
temtext,处置();。
temptext.Clear();。
}修订后的kdub:代码标签:->code=cSharp。
**** Hidden Message *****

n.yuan 发表于 2015-8-12 10:08:19

没有时间进行测试运行,但这可能是可能的原因:
您使用了静态 IntegerCollection,它只实例化一次作为添加/擦除瞬态图形的参数。每次调用添加/擦除瞬态图形时,都应将其实例化为新的 IntegerCollection。

nobody 发表于 2015-8-13 19:50:04

所以。。。试图根据我认为你的意思做很多事情....但对于一个卑微的cad家伙来说,这是很多大的编程词,巴哈哈....
无论如何,你可以帮我...傻乎乎的一点?

nobody 发表于 2015-8-13 20:04:17

它会偶尔清理吗
总是第一次工作吗
再也不工作了
有时第二次工作
等…

nobody 发表于 2015-8-13 23:20:10

在大多数情况下,如果我立即恢复,它会起作用。如果我在没有恢复的情况下再次执行该操作,它们往往会留下来。

Jeff_M 发表于 2015-8-13 23:58:10

据我所知,你为什么不打电话给regen就指望它能工作
根据我的猜测,您可以调用<br>DisplayText</strong>来添加临时文本添加命令启动处理程序,然后命令处理程序检查命令是否重新生成如果命令是Regen,它调用清除标记,然后删除命令启动处理程序

nobody 发表于 2015-8-14 00:39:18


感谢Jeff,这是我第一次尝试在civil 3d中使用瞬态图形,以及使用这样的事件处理程序。这里似乎是每个实例,在LUA等中,当我分配一个偶数处理程序时,无论该事件何时发生,无论我是将其放入函数中还是使其成为自己的,它都会触发。所有这些都有点让人困惑,哈哈。至少我似乎必须马上解雇Regen。如果我不这样做,文本将保持不变…这使我认为它是每个实例
应该说明我正在使用“regen”,它没有清除…所以不知道为什么
我暂时放弃了使用它,但希望在这个话题上有更多我可以学习的东西<非常感谢。

nobody 发表于 2015-8-14 10:52:08

Alien,我已经修改了您的代码,以便事件处理程序只在需要时添加一次,并删除文本的所有实例。如果这不是您想要完成的,也许可以解释更多?[命令方法("DoText")]。
公共无效dotext()。
{。
DisplayText(“测试”);。
}。
公共静态DBObjectCollection temtext=new DBObjectCollection();。
公共静态intColl=null;。
公共静态bool事件添加=false;。

公共静态无效DisplayText(string mystring)。
{。
intColl=new intgerCollection();。
文档acDoc=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;。
编辑我的编辑器=Application.DocumentManager.MdiActiveDocument.Editor;。
Point2d屏幕大小=(Point2d)Application.GetSystemVariable("SCREENSIZE");。
System.Drawing.Point新System.Drawing.Point。
System.Drawing.Pointlowerright=新的System.Drawing.Point((int)屏幕尺寸. X,(int)屏幕尺寸. Y);。
Point3d upperLeftWorld=MyEditor.PointToWorld(upper↓,0);。
Point3d lowerRightWorld=MyEditor.PointToWorld(lowerright,0);。
双屏幕大小=upperLeftWorld.DistanceTo(lowerRightWorld);。
如果(!事件添加)。
{。
acDoc.CommandWillStart+=新的命令事件处理程序(doc_CommandWillStart);。
事件添加=真;。
}。
DBText mytext=new DBText();。
mytext.TextString=mystring;。
mytext.Height=屏幕大小*.02;。
mytext.Position=新的Point3d(lowerRightWorld. X-20, lowerRightWorld. Y+20,0);。
mytext.ColorIndex=140;。
aGi.TransientManager.CurrentTransientManager.AddTransient(mytext,aGi.TransientDrawingMode.DirectTopmost,128, intColl);。
temptext.Add(mytext);。
}。
公共静态无效doc_CommandWillStart(对象发送者,命令EventArgs e)。
{。
如果(e.GlobalCommandName.Contains("REGEN"))。
{。
ClearMarkers();。
文档文档=Application.DocumentManager.MdiActiveDocument;。
doc.CommandWillStart-=新的命令事件处理程序(doc_CommandWillStart);。
事件添加=假;。
}。
}。
公共静态空ClearMarkers()。
{。
对于(int i=0; i。
{。
aGi.TransientManager.CurrentTransientManager.EraseTransient(temtext, intColl);。
temtext,处置();。
}。
temptext.Clear();。
}。

Jeff_M 发表于 2015-8-15 18:32:48

谢谢你。这正是我所需要的。
页: [1]
查看完整版本: 尝试显示瞬态文本