与不工作相交
我在2D中工作,并使用vb。网我有一条闭合多段线(矩形)。我有一条直线穿过它,也就是说,它相交两次。我使用以下代码:
Dim colIntersection作为新点3DCollection
糜棱线。IntersectWith(MyPolyLine,Intersect.OnBothOperands,\uColIntersection,1,1)
出于某种奇怪的原因,共线连接。计数始终等于1。一、 它只找到一个交点。
有人知道怎么把它们都弄到手吗? 我试过这个:
Dim colIntersection As Point3dCollection=新的Point3dCollection(myLine.IntersectWith(MyPolyLine))
我在论坛上看到了这个代码(http://www.cadtutor.net/forum/showthread.php?t=39190). 肖特提出了一个解决方案,他们声称它有效!
一、 另一方面,获取以下错误:错误1重载解析失败,因为没有可访问的“IntersectWith”接受此数量的参数。
使用上一篇文章中的代码,我添加了许多线,它们都与该多段线相交两次。我总是得到一个或没有交集点返回,从来没有2,因为我相信我应该得到。
听起来有人试图使用这行代码:
Dim ptArray() As Point3d = ls.IntersectWith(ra3d)
使用标准数据库曲线(无需先将其转换为Autodesk.AutoCAD.Geometry对应项)。
我也注意到你在theswamp上的帖子。org,其中似乎有解决问题的方法。 嗨,肖特,
我试图建立一个点的集合,这些点是由一条直线与一条多段线的交点产生的。
此代码无效。。。(AutoCAD不断向我发送“参数过多”消息,并且在删除“、intersectPoints,0,0”之前不允许我继续操作)。。。
作为Autodesk的公共交点。AutoCAD。几何学点3DCollection
正面1。相交(objACADEntity2,Intersect.OnBothOperands,intersectPoints,0,0)
我不确定这是否有效。。。但至少它没有出错。。。(这是上述代码,删除了“.intersectPoints,0,0”)。。。
正面1。相交(objACADEntity2,Intersect.OnBothOperands)
我为AutoCAD图元“objACADEntity1”指定了一条线
我为AutoCAD图元“objACADEntity2”指定了一条多段线
我是否需要将一些ACAD实体转换为其他实体才能构建此集合?
找到直线和多段线交点的秘密是什么??
感谢肖特的专业帮助!
这对你有用吗
<CommandMethod("inters", CommandFlags.UsePickSet)> _
Public Sub GetInters()
Dim doc As Document = acadApp.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim tr As Transaction = db.TransactionManager.StartTransaction
Try
Using (tr)
Dim opt AsNew PromptEntityOptions(vbLf & "Select line: ")
opt.SetRejectMessage(vbLf & "Select line only")
opt.AllowNone = False
opt.AllowObjectOnLockedLayer = True
opt.AddAllowedClass(GetType(Line), True)
Dim res As PromptEntityResult = ed.GetEntity(opt)
If res.Status <> PromptStatus.OK Then Return
Dim lid As ObjectId = res.ObjectId
opt.AddAllowedClass(GetType(Polyline), True)
opt.SetRejectMessage(vbLf & "Select polyline only")
opt.Message = vbLf & "Select polyline: "
res = ed.GetEntity(opt)
If res.Status <> PromptStatus.OK Then Return
Dim pid As ObjectId = res.ObjectId
Dim pts As Point3dCollection = New Point3dCollection()
ed.WriteMessage(vbLf & "{0} <> {1};", lid, pid)
Dim enl As Line = CType(tr.GetObject(lid, OpenMode.ForRead), Line)
Dim enp As Polyline = CType(tr.GetObject(pid, OpenMode.ForRead), Polyline)
Dim plane As Plane = New Plane(ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Origin, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis)
enl.IntersectWith(enp, Intersect.OnBothOperands, plane, pts, 0, 0)
ed.WriteMessage(vbLf & "Number of intersections: {0}", pts.Count)
Dim i As Integer = 1
For Each pt As Point3d In pts
ed.WriteMessage(vbLf & "Point number {0}: ({1}, {2}, {3})", i, pt.X, pt.Y, pt.Z)
i += 1
Next
tr.Commit()
End Using
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(vbLf & "{0}", ex.Message)
End Try
End Sub
~'J'~ 我正要发布一个示例,但看到fixo比我快到了。 来吧,朋友
你让我笑了
非常感谢。
~'J'~
不客气,菲索,谢谢你。
并向本论坛的其他贡献者表示“感谢”。愿我们在未来十年都有时间和意愿提供建议。 谢谢,但我无法将此代码用于我的系统。
如果我们从头开始,我想我们可能会发现问题。。。
什么会导致下面的代码段生成“找不到指定的模块”消息
作为Autodesk的公共交点。AutoCAD。几何学点3DCollection
你把这个包括在其余的进口货里了吗?
导入Autodesk。AutoCAD。几何学
页:
[1]
2