Hab mal im, Netz ein VB Journal gefunden das die maximale Ausprägung in Partattribute schreibt. Vielleicht hilft es ja:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module NXJournal
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim bbox(5) As Double
Dim dblAcc_Value(11) As Double
Dim dblMass_Props(46) As Double
Dim dblStats(12) As Double
Dim strOutput As String
Dim boundX As Double
Dim boundY As Double
Dim boundZ As Double
Dim minCorner(2) As Double
Dim boxDirections(2, 2) As Double
Dim boxDistances(2) As Double
Dim solid1 As Body = SelectSolid()
If solid1 Is Nothing Then
Return
End If
Dim tagList(0) As NXOpen.Tag
tagList(0) = solid1.Tag
'get volume
dblAcc_Value(0) = 0.999
'AskMassProps3d(in_Tags(),in_num_objs,in_type,in_units,in_density,in_accuracy,in_accuracy_values(),out_mass_props(),out_stats())
ufs.Modl.AskMassProps3d(tagList, 1, 1, 1, 0.0375, 1, dblAcc_Value, dblMass_Props, dblStats)
strOutput = "Surface Area: " & dblMass_Props(0) & vbcrlf
strOutput = strOutput & "Volume: " & dblMass_Props(1) & vbcrlf
strOutput = strOutput & "Mass: " & dblMass_Props(2) & vbcrlf
strOutput = strOutput & "COG: " & dblMass_Props(3) & ", " & dblMass_Props(4) & ", " & dblMass_Props(5) & vbcrlf
strOutput = strOutput & "Density: " & dblMass_Props(46)
' msgbox (strOutput, vbokonly)
'get solid body bounding box extents aligned to absolute csys
'ufs.Modl.AskBoundingBox(solid1.Tag, bbox)
'get solid body bounding box extents aligned to work csys (pass null tag to use work csys)
ufs.Modl.AskBoundingBoxAligned(solid1.Tag, Tag.Null, expand:=False, min_corner:=minCorner, directions:=boxDirections, distances:=boxDistances)
' msgbox ("min X: " & bbox(0) & " max X: " & bbox(3) & vbcrlf _
' & "min Y: " & bbox(1) & " max Y: " & bbox(4) & vbcrlf _
' & "min Z: " & bbox(2) & " max Z: " & bbox(5) & vbcrlf & vbcrlf & _
' "X dim: " & bbox(3) - bbox(0) & vbcrlf & _
' "Y dim: " & bbox(4) - bbox(1) & vbcrlf & _
' "Z dim: " & bbox(5) - bbox(2), vbokonly)
'boundX = bbox(3) - bbox(0)
'boundY = bbox(4) - bbox(1)
'boundZ = bbox(5) - bbox(2)
boundX = boxDistances(0)
boundY = boxDistances(1)
boundZ = boxDistances(2)
'convert units to inches, based on the part units of the work part
If workPart.PartUnits = Part.Units.Millimeters Then
'convert distances to inches
boundX = boundX / 25.4
boundY = boundY / 25.4
boundZ = boundZ / 25.4
End If
workPart.SetAttribute("Bounding_X", boundX.ToString("0.000"))
workPart.SetAttribute("Bounding_Y", boundY.ToString("0.000"))
workPart.SetAttribute("Bounding_Z", boundZ.ToString("0.000"))
End Sub
'**********************************************************
Public Function SelectSolid() As Body
Dim ui As UI = ui.GetUI
Dim message As String = "Select solid body"
Dim title As String = "Selection"
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim keepHighlighted As Boolean = False
Dim includeFeatures As Boolean = True
Dim selectionAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim selectionMask_array(1) As Selection.MaskTriple
Dim selectedObject As NXObject = Nothing
Dim cursor As Point3d
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
End With
ui.SelectionManager.SelectObject(message, title, scope, _
selectionAction, includeFeatures, _
keepHighlighted, selectionMask_array, _
selectedObject, cursor)
Dim solid As Body = CType(selectedObject, Body)
If solid Is Nothing Then
Return Nothing
End If
Return solid
End Function
'*******************
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
End Module
------------------
mfg
Leon
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP