请问如何画一个多边形,并获取该多边形里的图元?
请问如何画一个多边形,并获取该多边形里的图元? 哪位高手贴段代码参考下啊! 本帖最后由 guohq 于 2011-6-15 11:49 编辑Public Enum PolygonSelectType
''' <summary>
''' 圈交(实选)
''' </summary>
''' <remarks></remarks>
CrossingPolygon = 1
''' <summary>
''' 圈围(范选)
''' </summary>
''' <remarks></remarks>
WindowPolygon = 2
End Enum
Public Function SelectEntsByPolygon(ByVal objEditor As Editor, ByVal Pts As Point3dCollection, Optional ByVal sFilter As SelectionFilter = Nothing, Optional ByVal SelectType As PolygonSelectType = PolygonSelectType.CrossingPolygon) As ObjectId()
Dim resSel As PromptSelectionResult = Nothing
Select Case SelectType
Case 1
If sFilter Is Nothing Then
resSel = objEditor.SelectCrossingPolygon(Pts)
Else
resSel = objEditor.SelectCrossingPolygon(Pts, sFilter)
End If
Case 2
If sFilter Is Nothing Then
resSel = objEditor.SelectWindowPolygon(Pts)
Else
resSel = objEditor.SelectWindowPolygon(Pts, sFilter)
End If
Case Else
'暂时没有其它情况
End Select
If resSel.Value Is Nothing Then
Return New clsAADS.ObjectId() {}
Else
Return (resSel.Value.GetObjectIds())
End If
End Function
多边形的顶点坐标转到point3dcollection就不用说了吧 回复 guohq 的帖子
谢谢,请问你有C#的代码么?我现在只要获取到多边形里所有图元的ObjectId后,删除该多边形或刷新图层该怎么做.本人新手希望代码能全点,谢谢 自己找个网站翻译一下好了,C# 我也不会写,不过语法基本还是比较接近的。
http://www.developerfusion.com/tools/convert/vb-to-csharp/ 回复 guohq 的帖子
谢谢了!你能把整个代码给我看看么?我对方法里传的值看不明白 哪为高手帮帮忙啊!给个具体点的实例参考下啊 本帖最后由 zjh0603 于 2011-6-17 10:30 编辑
public static bool selctText(ObjectId idp, Point3dCollection point3D)
{
Document doc = Autodesk.AutoCAD.Applicati**ervices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database ;
bool fa = false;
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
object obj = tr.GetObject(idp, OpenMode.ForWrite);
Entity ent = (Entity)tr.GetObject(idp, OpenMode.ForWrite);
TypedValue[] TypValAr1 = new TypedValue;
TypValAr1.SetValue(new TypedValue((int)DxfCode.Start, "*TEXT"), 0);
SelectionFilter acSelFtr1 = new SelectionFilter(TypValAr1);
PromptSelectionResult acSStext;
acSStext = doc.Editor.SelectCrossingPolygon(point3D, acSelFtr1);
if (acSStext.Status == PromptStatus.OK)
{
foreach (ObjectId id in acSStext.Value.GetObjectIds())
{
Entity entT = (Entity)tr.GetObject(id, OpenMode.ForRead);
string Str="";
if (entT is DBText)
{
DBText DBt = (DBText)tr.GetObject(id, OpenMode.ForRead);
Str = DBt.TextString;
}
}
}
tr .Commit ();
}
}
不错的例子... 回复 zjh0603 的帖子
请问 ObjectId idp, Point3dCollection point3D 是什么值?我是用多段线画的多边形
页:
[1]
2