Hallo
Habe da einmal etwas gestrickt.
VB.net 2010
Grüsse
Dim objApp As SolidEdgeFramework.Application = Nothing
Dim objdoc As Object = Nothing
Dim SelSet As SolidEdgeFramework.SelectSet = Nothing
'Properties
Dim objPropertySets As SolidEdgeFramework.PropertySets = Nothing
Dim objProperties As SolidEdgeFramework.Properties = Nothing
Dim objProperty As SolidEdgeFramework.Property = Nothing
' Dim objModel As SolidEdgePart.Model
Dim objmodel As Object = Nothing
objApp = Marshal.GetActiveObject("SolidEdge.Application")
' Open the document.
objdoc = objApp.ActiveDocument ' may be part/assy/weld
Select Case objApp.ActiveDocumentType
Case DocumentTypeConstants.igDraftDocument
' MsgBox("Kein 3D-Modell")
End Select
'Prüffe ob Selektiert
SelSet = objApp.ActiveDocument.SelectSet
If SelSet.Count = 1 Then
' MsgBox("Ein Teil gewählt")
Call objApp.StartCommand(57873)
objApp.DisplayAlerts = False
objApp.Visible = False
objApp.WindowState = FormWindowState.Minimized
objdoc = objApp.ActiveDocument
End If
'grenzabmasse
Dim objUOM As SolidEdgeFramework.UnitsOfMeasure = Nothing
Dim Grösse(3) As String
Static dMin() As Double
Static dMax() As Double
Static dBreite As Double
Static dLänge As Double
Static dHöhe As Double
objUOM = objdoc.UnitsOfMeasure
ReDim dMax(2)
ReDim dMin(2)
objmodel = objdoc.Models.Item(1)
objmodel.Body.GetExactRange(dMin, dMax)
dLänge = Math.Sqrt((dMax(0) - dMin(0)) ^ 2) 'x/z Ebene
Grösse(1) = objUOM.FormatUnit(SolidEdgeFramework.UnitTypeConstants.igUnitDistance, dLänge)
dBreite = Math.Sqrt((dMax(1) - dMin(1)) ^ 2) 'y/z Ebene
Grösse(2) = objUOM.FormatUnit(SolidEdgeFramework.UnitTypeConstants.igUnitDistance, dBreite)
dHöhe = Math.Sqrt((dMax(2) - dMin(2)) ^ 2) 'x/y Ebene
Grösse(3) = objUOM.FormatUnit(SolidEdgeFramework.UnitTypeConstants.igUnitDistance, dHöhe)
Array.Sort(Grösse)
Dim l As String
Dim b As String
Dim dicke As String
Dim variables As SolidEdgeFramework.Variables = Nothing
variables = DirectCast(objdoc.Variables, SolidEdgeFramework.Variables)
'Abwicklung:
l = Math.Round(variables.Item("Flat_Pattern_Model_CutSizeX").value * 1000, 2)
b = Math.Round(variables.Item("Flat_Pattern_Model_CutSizeY").value * 1000, 2)
dicke = Math.Round(variables.Item("Materialstärke").value * 1000, 2)
If Not (objmodel Is Nothing) Then
Marshal.ReleaseComObject(objmodel)
objmodel = Nothing
End If
If Not (SelSet Is Nothing) Then
Marshal.ReleaseComObject(SelSet)
SelSet = Nothing
End If
If Not (objdoc Is Nothing) Then
Marshal.ReleaseComObject(objdoc)
objdoc = Nothing
End If
If Not (objApp Is Nothing) Then
Marshal.ReleaseComObject(objApp)
objApp = Nothing
GC.Collect()
End If
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP