nobody 发表于 2016-7-14 01:07:52

瞬态图形

直到今晚,我一直避免短暂的图形。我把一些东西永久地卡在了一幅画里,从那以后,它给了我一点临阵退缩的感觉。我想沿着光标画一个圆,下面的代码显示我正在监视我的光标位置,但是我的圆圈只有在我重新生成时才会更新。我想让圆圈简单地跟随我的光标,感谢任何帮助。谢谢!   使用Autodesk,应用服务;。
使用Autodesk,AutoCAD . DatabaseServices。
使用Autodesk,AutoCAD . EditorInput。
使用Autodesk,AutoCAD .几何图形;。
使用Autodesk,AutoCAD . Runtime。
使用graphicinterface = Autodesk,AutoCAD . GraphicsInterface。

公共类PointMonitorTooltips。

{。
private static DBObjectCollection markers = new DBObjectCollection();。
private static integer collection collections = new integer collection();。
私静圈圈;。


公共静态void StartMonitor()。
{。

编辑器ed =应用程序,document manager . mdiactivedocument . editor;。
Point3d ctrPt = new Point3d(0,0,0);。
circle = new Circle(ctrPt,Vector3d。扎克斯,5);。
圆,ColorIndex = 1;。
图形界面,transient manager . currenttransientmanager . add transient(circle,graphicinterface。TransientDrawingMode . direct topmost,128,collectints);。
标记,加(圈);。
ed,point monitor+= new PointMonitor eventhandler(ed _ point monitor);。
}。


公共静态void StopMonitor()。
{。
编辑器ed =应用程序,document manager . mdiactivedocument . editor;。
ed,point monitor-= new PointMonitor eventhandler(ed _ point monitor);。
图形界面,transient manager . currenttransientmanager . erase transient(markers,collectints);。
标记,dispose();。
标记,clear();。
}。

静态void ed_PointMonitor(对象发送方,PointMonitorEventArgs e)。
{。
Editor ed =(Editor)sender;。
文档doc = ed,文档;。
圆,Center = e . Context.RawPoint。
}。
}。


**** Hidden Message *****

huiz 发表于 2016-7-14 01:49:22

你最好用实体夹具
请看这里的示例:http://spiderinnet1.typepad.com/blog/2013/05/autocad-jig-vbnet-keyword-support-for-circle-jigging-using-entityjig.html
这是一个很好的例子

Atook 发表于 2016-7-14 02:20:31

jig很可能是您想要的,如果您决定不使用它,您需要更新点监视器中的瞬态图形。我在我的点监视器中调用了此方法,并将绘图列表以及最后一点传递给它。将来我会将文本等添加到绘图列表中,但现在它是一个圆圈和一条橡胶带线。我想将其转换为jig,但jigs将我的注意力转向了有趣的方向。也许有一天,私有静态空UpdateTransGraphics(List绘图,Point3d原始Pt,Point3d lastPt,Point3dCollection rubberBandPoint)。
{。
//替换我们的每个抽屉。

矩阵3d垫=。
Matrix3d.Displacement(originPt.GetVectorTo(lastPt));。

//更新他们的图形。

循环cir=绘图为循环;。
如果(cir!=null)。
{。
cir.Center=lastPt;。
TransientManager.CurrentTransientManager.UpdateTransient(cir,新的intgerCollection());。
}。

//绘制橡皮筋。
折线rBand=绘图作为折线;。
如果(rBand!=null&&rubberBandPoints.Count>0)。
{。
rBand.Reset(false,0);。
对于(int i=0; i。
{。
Point2d pt=new Point2d(rubberBandPoint. X, rubberBandPoint. Y);。
rBand.AddVertexAt(i, pt,0,0,0);。
}。
rBand.AddVertexAt(rubberBandPoints.Count,lastPt.Convert2D(),0,0,0);。
TransientManager.CurrentTransientManager.UpdateTransient(rBand,新的IntgerCollection());。
}。
Debug.WriteLine(更新+drawables.Count+转换);。
}。

SEANT 发表于 2016-7-14 04:34:58

与OP中列出的要求不完全匹配,但我在此附上的代码(post#5):
http://www.cadtutor.net/forum/showthread.php?41649-VB。net-Create-a-circle<br>可作为光标定位圆的“抖动”示例。它实际上使用了两个跳汰元素,第一个用于创建/调整圆的大小,第二个用于通过圆心放置圆
这里是例行程序的屏幕放映:
http://autode.sk/29GlZIi

Jeff_M 发表于 2016-7-14 12:06:24

Alien Dude,当在Sincpac的PipeEditor命令中要求用户选择一个位置时,我使用TransientGraphics来跟随光标。这就是我如何使用Autodesk修改您的代码,使其类似于下面这样:   。应用服务;。
使用Autodesk,AutoCAD . DatabaseServices。
使用Autodesk,AutoCAD . EditorInput。
使用Autodesk,AutoCAD .几何图形;。
使用Autodesk,AutoCAD . Runtime。
使用aGi = Autodesk,AutoCAD . GraphicsInterface。

公共类PointMonitorTooltips。
{。
私有静态dbobject collection m _ markers = new dbobject collection();。
private static integer collection collections = new integer collection();。


公共静态void StartMonitor()。
{。
编辑器ed =应用程序,document manager . mdiactivedocument . editor;。
ed,point monitor+= new PointMonitor eventhandler(ed _ point monitor);。
}。


公共静态void stopmonitor()。
{。
编辑器ed =应用程序,document manager . mdiactivedocument . editor;。
ed,point monitor-= ed _ point monitor;。
clear markers();。
}。
静态void ed_PointMonitor(对象发送方,PointMonitorEventArgs e)。
{。
show circle(e . context . raw point);。
}。

静态void showcircle(Point3d pt)。
{。
clear markers();。
Circle circle = new Circle(pt,Vector3d。扎克斯,5);。
圆,ColorIndex = 1;。
m标记,加(圈);。
aGi,transient manager . currenttransientmanager . add transient(circle,aGi。TransientDrawingMode . directshorterm,128,collectints);。
}。

静态void ClearMarkers()。
{。
for(int I = 0;i 。
{。
aGi,transient manager . currenttransientmanager . erase transient(m _ markers,collectints);。
m_markers,dispose();。
}。
m标记,clear();。
}。
}。

nobody 发表于 2016-7-14 16:00:36

谢谢你这个

Chumplybum 发表于 2016-7-15 00:14:02

你也可以试试光标徽章,http://through-the-interface.typepad.com/through_the_interface/2014/05/adding-a-cursor-badge-in-autocad-2015-using-net.html

nobody 发表于 2016-7-21 02:44:58


喜欢他发布的内容...可惜还是在2014年:/
页: [1]
查看完整版本: 瞬态图形