求助!!!怎么得到三维实体的表面积???
需要估算油漆,怎么在三维实体模型中得到表面积? 2009以上版本可以引用acdbmgdbrep.dll以下就没有直接的办法了 感觉这样可以解决,但不知道怎么验证是否正确
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Public Class Class1
<CommandMethod("xarea")> _
Public Sub xarea()
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim toal As Double = 0
Using trans As Transaction = db.TransactionManager.StartOpenCloseTransaction()
Dim value(0) As TypedValue
value(0) = New TypedValue(DxfCode.Start, "3DSOLID")
Dim fill As SelectionFilter = New SelectionFilter(value)
Dim optsel As New PromptSelectionOptions()
optsel.MessageForAdding = "选择实体:"
Dim selrec As PromptSelectionResult = ed.GetSelection(fill)
If selrec.Status = PromptStatus.OK Then
Dim mysel As SelectionSet = selrec.Value
For Each xobj As SelectedObject In mysel
If Not IsDBNull(xobj) Then
Dim ent As Solid3d = trans.GetObject(xobj.ObjectId, OpenMode.ForRead)
If Not IsDBNull(ent) Then
Dim axarae As Double = ent.Area
toal = toal + axarae
ed.WriteMessage(CStr(toal))
End If
End If
Next
End If
End Using
End Sub
End Class Solid3d居然有Area属性。。。是我想复杂了
public static void Test123()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var resEnt = ed.GetEntity("select a Solid3d:");
using (var tr = new DBTransaction())
{
var s = tr.GetObject<Solid3d>(resEnt.ObjectId);
ed.WriteMessage(s.Area.ToString());
}
}
测试的结果没有问题
页:
[1]