Option Strict Off Imports System Imports NXOpen Module NXJournal999 Public theSession As Session = Session.GetSession() Public theUI As UI = UI.GetUI() Public dP As Part = theSession.Parts.Display Sub Main() theSession.ListingWindow.Open() Dim BB As cBoundingBox = GetBoundingBox() theSession.ListingWindow.WriteLine(BB.Corner1.X & "/" & BB.Corner1.Y & "/" & BB.Corner1.Z & " - " & _ BB.Corner2.X & "/" & BB.Corner2.Y & "/" & BB.Corner2.Z) Dim Box As Features.BlockFeatureBuilder = dP.Features.CreateBlockFeatureBuilder(Nothing) Box.SetTwoDiagonalPoints(BB.Corner1, BB.Corner2) Box.Commit() End Sub Private Sub GetKanten(ByVal aktPart As Part, ByRef Liste() As Edge) For Each aktBody As Body In aktPart.Bodies For Each Kante As Edge In aktBody.GetEdges() If Kante.IsBlanked = False Then theSession.ListingWindow.WriteLine(Kante.JournalIdentifier) If Liste Is Nothing Then ReDim Liste(0) Liste(0) = Kante Else ReDim Preserve Liste(Liste.Length) Liste(Liste.Length - 1) = Kante End If End If Next Next If Not aktPart.ComponentAssembly.RootComponent Is Nothing Then For Each Comp As Assemblies.Component In aktPart.ComponentAssembly.RootComponent.GetChildren() If Comp.IsBlanked = False Then 'Dim P As Part = Comp.Prototype Try Dim P As Part = theSession.Parts.FindObject("@DB/" & Comp.DisplayName) GetKanten(P, Liste) Catch ex As Exception End Try End If Next End If End Sub Private Function GetBoundingBox() As cBoundingBox Dim Wert As New cBoundingBox() Dim Kanten() As Edge = Nothing GetKanten(dP, Kanten) For Each E As Edge In Kanten Dim Vert1 As Point3d = Nothing, Vert2 As Point3d = Nothing E.GetVertices(Vert1, Vert2) If Vert1.X < Wert.Corner1.X Then Wert.Corner1.X = Vert1.X If Vert1.X > Wert.Corner2.X Then Wert.Corner2.X = Vert1.X If Vert1.Y < Wert.Corner1.Y Then Wert.Corner1.Y = Vert1.Y If Vert1.Y > Wert.Corner2.Y Then Wert.Corner2.Y = Vert1.Y If Vert1.Z < Wert.Corner1.Z Then Wert.Corner1.Z = Vert1.Z If Vert1.Z > Wert.Corner2.Z Then Wert.Corner2.Z = Vert1.Z If Vert2.X < Wert.Corner1.X Then Wert.Corner1.X = Vert2.X If Vert2.X > Wert.Corner2.X Then Wert.Corner2.X = Vert2.X If Vert2.Y < Wert.Corner1.Y Then Wert.Corner1.Y = Vert2.Y If Vert2.Y > Wert.Corner2.Y Then Wert.Corner2.Y = Vert2.Y If Vert2.Z < Wert.Corner1.Z Then Wert.Corner1.Z = Vert2.Z If Vert2.Z > Wert.Corner2.Z Then Wert.Corner2.Z = Vert2.Z Next Return Wert End Function Public Class cBoundingBox Public Corner1 As Point3d = Nothing Public Corner2 As Point3d = Nothing Public Sub New() Dim Wert As Double = 999999999 Corner1 = New Point3d(Wert, Wert, Wert) Corner2 = New Point3d(-Wert, -Wert, -Wert) End Sub End Class End Module