乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 126|回复: 8

尝试显示瞬态文本

[复制链接]

129

主题

422

帖子

5

银币

中流砥柱

Rank: 25

铜币
936
发表于 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[0], intColl);。
temtext[0],处置();。
temptext.Clear();。
}修订后的kdub:代码标签:->code=cSharp。

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

4

主题

219

帖子

4

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
238
发表于 2015-8-12 10:08:19 | 显示全部楼层
没有时间进行测试运行,但这可能是可能的原因:
您使用了静态 IntegerCollection,它只实例化一次作为添加/擦除瞬态图形的参数。每次调用添加/擦除瞬态图形时,都应将其实例化为新的 IntegerCollection。
回复

使用道具 举报

129

主题

422

帖子

5

银币

中流砥柱

Rank: 25

铜币
936
发表于 2015-8-13 19:50:04 | 显示全部楼层
所以。。。试图根据我认为你的意思做很多事情....但对于一个卑微的cad家伙来说,这是很多大的编程词,巴哈哈....
无论如何,你可以帮我...傻乎乎的一点?
回复

使用道具 举报

129

主题

422

帖子

5

银币

中流砥柱

Rank: 25

铜币
936
发表于 2015-8-13 20:04:17 | 显示全部楼层
它会偶尔清理吗
总是第一次工作吗
再也不工作了
有时第二次工作
等…
回复

使用道具 举报

129

主题

422

帖子

5

银币

中流砥柱

Rank: 25

铜币
936
发表于 2015-8-13 23:20:10 | 显示全部楼层
在大多数情况下,如果我立即恢复,它会起作用。如果我在没有恢复的情况下再次执行该操作,它们往往会留下来。
回复

使用道具 举报

71

主题

928

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1230
发表于 2015-8-13 23:58:10 | 显示全部楼层
据我所知,你为什么不打电话给regen就指望它能工作
根据我的猜测,您可以调用<br>DisplayText</strong>来添加临时文本添加命令启动处理程序,然后命令处理程序检查命令是否重新生成如果命令是Regen,它调用清除标记,然后删除命令启动处理程序
回复

使用道具 举报

129

主题

422

帖子

5

银币

中流砥柱

Rank: 25

铜币
936
发表于 2015-8-14 00:39:18 | 显示全部楼层

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

使用道具 举报

129

主题

422

帖子

5

银币

中流砥柱

Rank: 25

铜币
936
发表于 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[i], intColl);。
temtext[i],处置();。
}。
temptext.Clear();。
}。

回复

使用道具 举报

71

主题

928

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1230
发表于 2015-8-15 18:32:48 | 显示全部楼层
谢谢你。这正是我所需要的。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-2-5 00:53 , Processed in 0.251521 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表