提取多曲面边界
你好,我对AutoCAD有点陌生。NET代码和编程,最近几年这成了我的新爱好,对我的工作也很有帮助(我经常使用autocad软件)。我有一个问题,为多个表面创建一个三维折线的表面边界,这有助于BIM ppl更有效地处理表面。它适用于“浏览”中的第一个曲面,然后停止。所以我必须运行命令并移除表面,运行命令并移除表面,直到所有的表面边界被创建。我不明白为什么,因为我把每个表面的代码都放在了图中。任何帮助都将不胜感激。代码:导入系统
导入Autodesk。AutoCAD.Runtime
导入Autodesk。应用服务
导入Autodesk。AutoCAD.DatabaseServices
导入Autodesk。AutoCAD.Geometry
导入Autodesk。AutoCAD.EditorInput
导入Autodesk。Civil.DatabaseServices
导入Autodesk。Civil.ApplicationServices
'这一行不是强制的,但可以提高加载性能
命名空间surface boundary
Public Class my commands
Dim Borders As objectid collection = Nothing
Public Sub MyCommand()'此方法可以有任何名称
Dim doc As Document = Application。document manager . MdiActiveDocument
Dim db As Database = doc。数据库
显示为Editor = doc。editor
Dim civ doc As civil document = Autodesk。civil . application services . civil application . active document。transaction manager . start transaction()
Dim oBlockTable As block table。GetObject(db。BlockTableId,OpenMode。for read)
Dim oBTR As block table record
oBTR = trans。GetObject(oBlockTable(block table record。ModelSpace)、OpenMode。ForWrite)
尝试
Dim obids As objectid collection = civ doc。GetSurfaceIds()
For Each ob As ObjectId In obids
Dim surface As TinSurface = try cast(trans。GetObject(ob,OpenMode。ForRead),tin surface)
Dim entity ids As objectid collection
entity ids = surface。ExtractBorder(Autodesk。civil . surface extractionsettingstype . model)
For I As Integer = 0 To entity ids。count-1
Dim entityId As ObjectId = entityIds(I)
If entityId。ObjectClass = RXClass。GetClass(GetType(Polyline3d))然后
Dim border As polyline 3d = try cast(entityId。GetObject(OpenMode。ForWrite)、Polyline3d)
oBTR。append entity(border)trans。AddNewlyCreatedDBObject(border,True)
End If
Next
Next
trans。commit()
Catch
End Try
trans。dispose()
End Sub
End Class
End Namespace
**** Hidden Message ***** 如果你取消尝试...你会看到它在oBTR行抛出一个错误。AppendEntity(边框)。错误是eAlreadyInDb,因为它随后退出For Each循环,所以您只能得到一条折线。删除这一行和它后面的一行,代码运行正常。尽管您应该添加一个检查来验证表面不为null/nothing,因为如果遇到Grid或TinVolume表面类型,代码将会失败。 谢谢提供信息的家伙
页:
[1]