Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Interop Imports PSCOMWRAPPERLib _ Sub GetWeight() Dim selection As New Ks_ComSelection Dim property_ps As New Ks_ComProperty Dim entity As Common.AcadEntity Dim mWeight As Double Dim mLength As Double Dim Msg As String Dim Result As Long Dim Index As Integer System.Diagnostics.Debugger.Break() selection.SetSelectionFilter(KsSelectionFilter.kFilterAllSteel) Result = selection.SelectObjects("Elemente für Gewicht waählen") If Result = 0 Then Result = selection.SelectAllObjects If Result > 0 Then For Index = 0 To selection.ObjectCount - 1 entity = selection.GetObject(Index) property_ps.ReadFrom(entity) MsgBox(property_ps.ObjectType) mWeight += property_ps.Weight If mLength < property_ps.Length Then mLength += property_ps.Length 'entity.Visible = False Next mWeight = Format(mWeight, "##,##0.000") mLength = Format(mLength, "##,##0.0") Msg = "Gesamtgewicht alle gewählten ProSteel 3D Elemente beträgt " & mWeight & " kg" & vbNewLine Msg = Msg & "Die Länge des längsten Bauteils beträgt " & mLength & " mm" & vbNewLine MsgBox(Msg, vbApplicationModal, "Gewichts- und Längenermittlung") Else MsgBox("*** Keine ProSteel Elemente gefunden ***" & vbNewLine & "Befehl: ") End If End Sub End Class