关于经过两点的各类线获取
<p><font face="Verdana"> 我用的如下代码:</font></p><p><font face="Verdana"><font face="Verdana"> Dim acTypValAr(0) As TypedValue</font></font></p>
<p><font face="Verdana"> acTypValAr.SetValue(New TypedValue(DxfCode.Start, "*Line"), 0)<br/> Dim pc As New Point3dCollection<br/> pc.Add(ss.pos)<br/> pc.Add(ps.pos)<br/> Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)<br/> Dim acSSPrompt As PromptSelectionResult = ed.SelectFence(pc, acSelFtr)<br/> Dim acSSet As SelectionSet = acSSPrompt.Value</font></p>
<p><font face="Verdana"> If Not acSSet Is Nothing Then<br/> obc = acSSet.GetObjectIds</font></p>
<p> end if</p>
<p>奇怪的是,明明经过两点的直线只有一条,却总是得到好几条,并且从我调试的前几个点来看,筛选的obc里头,一般都是最后一个才是真正要获取的,这是为什么啊?</p> 栏选的方式是与两点连线有交点的图元就会被选中,你可以选择后在遍历过滤一下 那有什么更好的方法只选择startpoint和endpoint只为给出的两点的线呢?上面方法对于大图来说,搜索时间太烦 <p>过滤组码10/11</p> <p><font face="Verdana"> 这样吗?但是我搜索不到线条</font></p>
<p><font face="Verdana"> Dim acTypValAr(4) As TypedValue<br/> acTypValAr.SetValue(New TypedValue(DxfCode.Start, "*Line"), 0)<br/> acTypValAr.SetValue(New TypedValue(-4, "<OR"), 1)<br/> acTypValAr.SetValue(New TypedValue(10, ss.pos), 2)<br/> acTypValAr.SetValue(New TypedValue(11, ps.pos), 3)<br/> acTypValAr.SetValue(New TypedValue(-4, "OR>"), 4)<br/> Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)<br/> Dim acSSPrompt As PromptSelectionResult = ed.SelectAll(acSelFtr)<br/> Dim acSSet As SelectionSet = acSSPrompt.Value</font></p>
public static void test25()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
var resPt1 = ed.GetPoint("\n请输入第一点:");
if (resPt1.Status != PromptStatus.OK)
return;
var resPt2 = ed.GetPoint("\n请输入第二点:");
if (resPt2.Status != PromptStatus.OK)
return;
var resSel =
ed.SelectAll(
new ResultList
{
{0, "line"},
{-4, "<xor"},
{-4, "<and"},
{10, resPt1.Value},
{11, resPt2.Value},
{-4, "and>"},
{-4, "<and"},
{10, resPt2.Value},
{11, resPt1.Value},
{-4, "and>"},
{-4, "xor>"}
});
if (resSel.Status == PromptStatus.OK)
ed.SetImpliedSelection(resSel.Value.GetObjectIds());
}
<p>我按照 版主的代码改了,但是还是没有?</p>
<p><font face="Verdana"> Dim acTypValAr(10) As TypedValue<br/> acTypValAr.SetValue(New TypedValue(DxfCode.Start, "*Line"), 0)<br/> acTypValAr.SetValue(New TypedValue(-4, "<XOR"), 1)<br/> acTypValAr.SetValue(New TypedValue(-4, "<AND"), 2)<br/> acTypValAr.SetValue(New TypedValue(10, ss.pos), 3)<br/> acTypValAr.SetValue(New TypedValue(11, ps.pos), 4)<br/> acTypValAr.SetValue(New TypedValue(-4, "AND>"), 5)<br/> acTypValAr.SetValue(New TypedValue(-4, "<AND"), 6)<br/> acTypValAr.SetValue(New TypedValue(10, ps.pos), 7)<br/> acTypValAr.SetValue(New TypedValue(11, ss.pos), 8)<br/> acTypValAr.SetValue(New TypedValue(-4, "AND>"), 9)<br/> acTypValAr.SetValue(New TypedValue(-4, "XOR>"), 10)<br/> Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)<br/> Dim acSSPrompt As PromptSelectionResult = ed.SelectAll(acSelFtr)</font></p> <p><font face="Verdana">多段线用下面的</font></p>
<p><font face="Verdana">{0 , "LWPOLYLINE"},</font></p>
<p>{10, ss.pos},</p>
<p>{10, ps.pos}</p> <p>版主,好像还是没有唉,我搜索所有直线包括多段线,或者单独多段线也不行。</p> 我这里测试是正常的
var resSel =
ed.SelectAll(
new ResultList
{
{-4, "<or"},
{-4, "<and"},
{0, "line"},
{-4, "<xor"},
{-4, "<and"},
{10, resPt1.Value},
{11, resPt2.Value},
{-4, "and>"},
{-4, "<and"},
{10, resPt2.Value},
{11, resPt1.Value},
{-4, "and>"},
{-4, "xor>"},
{-4, "and>"},
{-4, "<and"},
{0, "lwpolyline"},
{10, resPt1.Value},
{10, resPt2.Value},
{-4, "and>"},
{-4, "or>"},
});
页:
[1]
2