Here's a UDO that creates a Bounding Box. It also adds PMI dimensions to the bounding box.
Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.BlockStyler
Imports NXOpen.UserDefinedObjects
Imports NXOpen.Annotations
Module BoundingBoxUdoFeature
Dim theSession As Session = Nothing
Dim theUFSession As UFSession = Nothing
Dim bbClass As UserDefinedClass = Nothing
Dim bbUdo As UserDefinedObject = Nothing
Sub Echo(ByVal output As String)
theSession.ListingWindow.Open()
theSession.ListingWindow.WriteLine(output)
theSession.LogFile.WriteLine(output)
End Sub
Sub Show_boundingBox()
Dim theboundingBox As boundingBox
Try
theboundingBox = New boundingBox()
theboundingBox.Show()
theboundingBox.Dispose()
Catch ex As Exception
Echo("Caught Exception in Show_boundingBox: '" & ex.Message() & "'")
End Try
End Sub
Public Function bbUpdateCB(ByVal editEvent As UserDefinedLinkEvent) As Integer
Try
bbUpdateCB = 0
bbUdo = editEvent.UserDefinedObject
Dim links() As UserDefinedObject.LinkDefinition = bbUdo.GetLinks(UserDefinedObject.LinkType.Type3)
Dim anyAlive As Boolean = False
For ii As Integer = 0 To links.Length - 1
If theUFSession.Obj.AskStatus(links(ii).AssociatedObject.Tag) = UFConstants.UF_OBJ_ALIVE Then
anyAlive = True
End If
Next
If Not anyAlive Or links.Length < 1 Then 'Last object to be inside box has been deleted
Dim objects1() As NXObject = {bbUdo.GetUserDefinedObjectFeature, bbUdo}
theSession.UpdateManager.AddToDeleteList(objects1)
Return 0
End If
' Echo("anyAlive = " & anyAlive & ", links.length = " & links.Length)
Dim clinks() As UserDefinedObject.LinkDefinition = bbUdo.GetLinks(UserDefinedObject.LinkType.Type2)
Dim csys As CartesianCoordinateSystem = clinks(0).AssociatedObject
Dim corner(2) As Double
Dim farCorner(2) As Double
Dim dirs(2, 2) As Double
Dim deltas(2) As Double
Dim minCorner(2) As Double
Dim maxCorner(2) As Double
Dim maxDeltas(2) As Double
Dim first As Boolean = True
For ii As Integer = 0 To links.Length - 1
If Not theUFSession.Obj.AskStatus(links(ii).AssociatedObject.Tag) = UFConstants.UF_OBJ_ALIVE Then
Continue For
End If
theUFSession.Modl.AskBoundingBoxExact(links(ii).AssociatedObject.Tag, csys.Tag, corner, dirs, deltas)
For jj As Integer = 0 To 2
farCorner(jj) = corner(jj)
For kk As Integer = 0 To 2
farCorner(jj) += dirs(kk, jj) * deltas(kk)
Next
Next
mapAbs2Dirs(dirs, corner)
mapAbs2Dirs(dirs, farCorner)
If first Then
theUFSession.Vec3.Copy(corner, minCorner)
theUFSession.Vec3.Copy(farCorner, maxCorner)
first = False
Else
For jj As Integer = 0 To 2
If corner(jj) < minCorner(jj) Then
minCorner(jj) = corner(jj)
End If
If farCorner(jj) > maxCorner(jj) Then
maxCorner(jj) = farCorner(jj)
End If
Next
End If
Next
Dim vecX() As Double = {dirs(0, 0), dirs(0, 1), dirs(0, 2)}
Dim vecY() As Double = {dirs(1, 0), dirs(1, 1), dirs(1, 2)}
Dim vecZ() As Double = {dirs(2, 0), dirs(2, 1), dirs(2, 2)}
Dim oldmag As Double = Nothing
theUFSession.Vec3.Sub(maxCorner, minCorner, maxDeltas)
bbUdo.SetLengths(maxDeltas)
theUFSession.Vec3.Unitize(vecX, 0, oldmag, vecX)
theUFSession.Vec3.Unitize(vecY, 0, oldmag, vecY)
theUFSession.Vec3.Unitize(vecZ, 0, oldmag, vecZ)
mapDirs2Abs(dirs, minCorner)
theUFSession.Vec3.Scale(maxDeltas(0), vecX, vecX)
theUFSession.Vec3.Scale(maxDeltas(1), vecY, vecY)
theUFSession.Vec3.Scale(maxDeltas(2), vecZ, vecZ)
Dim tol As Double = Nothing
theUFSession.Modl.AskDistanceTolerance(tol)
Dim isZero(2) As Integer
theUFSession.Vec3.IsZero(vecX, tol, isZero(0))
theUFSession.Vec3.IsZero(vecY, tol, isZero(1))
theUFSession.Vec3.IsZero(vecZ, tol, isZero(2))
If isZero(0) + isZero(1) + isZero(2) > 0 Then
Echo("Selected object is not 3D cannot create Bounding Box")
bbUdo.GetUserDefinedObjectFeature.Suppress()
bbUpdateCB = 1
Else
If bbUdo.GetUserDefinedObjectFeature.Suppressed Then
bbUdo.GetUserDefinedObjectFeature.Unsuppress()
End If
Dim corners(7) As Point3d
Dim cornerNxPoints(7) As Point
corners(0) = New Point3d(minCorner(0), minCorner(1), minCorner(2))
cornerNxPoints(0) = theSession.Parts.Work.Points.CreatePoint(corners(0))
cornerNxPoints(0).SetVisibility(SmartObject.VisibilityOption.Invisible)
Dim coords(2) As Double
theUFSession.Vec3.Add(minCorner, vecX, coords)
corners(1) = New Point3d(coords(0), coords(1), coords(2))
cornerNxPoints(1) = theSession.Parts.Work.Points.CreatePoint(corners(1))
cornerNxPoints(1).SetVisibility(SmartObject.VisibilityOption.Invisible)
theUFSession.Vec3.Add(coords, vecZ, coords)
corners(2) = New Point3d(coords(0), coords(1), coords(2))
cornerNxPoints(2) = theSession.Parts.Work.Points.CreatePoint(corners(2))
cornerNxPoints(2).SetVisibility(SmartObject.VisibilityOption.Invisible)
theUFSession.Vec3.Add(minCorner, vecZ, coords)
corners(3) = New Point3d(coords(0), coords(1), coords(2))
cornerNxPoints(3) = theSession.Parts.Work.Points.CreatePoint(corners(3))
cornerNxPoints(3).SetVisibility(SmartObject.VisibilityOption.Invisible)
theUFSession.Vec3.Add(minCorner, vecY, coords)
corners(4) = New Point3d(coords(0), coords(1), coords(2))
cornerNxPoints(4) = theSession.Parts.Work.Points.CreatePoint(corners(4))
cornerNxPoints(4).SetVisibility(SmartObject.VisibilityOption.Invisible)
theUFSession.Vec3.Add(coords, vecX, coords)
corners(5) = New Point3d(coords(0), coords(1), coords(2))
cornerNxPoints(5) = theSession.Parts.Work.Points.CreatePoint(corners(5))
cornerNxPoints(5).SetVisibility(SmartObject.VisibilityOption.Invisible)
theUFSession.Vec3.Add(coords, vecZ, coords)
corners(6) = New Point3d(coords(0), coords(1), coords(2))
cornerNxPoints(6) = theSession.Parts.Work.Points.CreatePoint(corners(6))
cornerNxPoints(6).SetVisibility(SmartObject.VisibilityOption.Invisible)
theUFSession.Vec3.Sub(coords, vecX, coords)
corners(7) = New Point3d(coords(0), coords(1), coords(2))
cornerNxPoints(7) = theSession.Parts.Work.Points.CreatePoint(corners(7))
cornerNxPoints(7).SetVisibility(SmartObject.VisibilityOption.Invisible)
Dim starts() As Integer = {0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7}
Dim ends() As Integer = {1, 2, 3, 0, 4, 5, 6, 7, 5, 6, 7, 4}
Dim line_links() As UserDefinedObject.LinkDefinition = bbUdo.GetLinks(UserDefinedObject.LinkType.Owning)
If line_links.Length < 1 Then
System.Array.Resize(line_links, 15)
For ii As Integer = 0 To 11
line_links(ii) = New UserDefinedObject.LinkDefinition
line_links(ii).AssociatedObject = theSession.Parts.Work.Curves.CreateLine(corners(starts(ii)), corners(ends(ii)))
Next
Dim newPmiWidth As PmiParallelDimension = Nothing
line_links(12).AssociatedObject = newPmiWidth
Dim newPmiHeight As PmiParallelDimension = Nothing
line_links(13).AssociatedObject = newPmiHeight
Dim newPmiLength As PmiParallelDimension = Nothing
line_links(14).AssociatedObject = newPmiLength
bbUdo.SetLinks(UserDefinedObject.LinkType.Owning, line_links)
Else
For ii As Integer = 0 To 11
Dim aline As Line = line_links(ii).AssociatedObject
aline.SetEndpoints(corners(starts(ii)), corners(ends(ii)))
Next
Dim dimOrigin As Point3d
Dim dirVector As Vector3d
Dim pmiWidth As PmiParallelDimension = line_links(12).AssociatedObject
dirVector = CreateVector(corners(0), corners(3))
dimOrigin.X = (corners(0).X + corners(1).X) / 2 + 1 * dirVector.X
dimOrigin.Y = (corners(0).Y + corners(1).Y) / 2 + 1 * dirVector.Y
dimOrigin.Z = (corners(0).Z + corners(1).Z) / 2 + 1 * dirVector.Z
pmiWidth = DimPtToPt(cornerNxPoints(0), cornerNxPoints(1), dimOrigin, "XZ")
pmiWidth.SetUserAttribute("PMI", 0, "Width", Update.Option.Now)
' YZ Dimension
Dim pmiHeight As PmiParallelDimension = line_links(13).AssociatedObject
dirVector = CreateVector(corners(1), corners(2))
dimOrigin.X = (corners(1).X + corners(5).X) / 2 + 1 * dirVector.X
dimOrigin.Y = (corners(1).Y + corners(5).Y) / 2 + 1 * dirVector.Y
dimOrigin.Z = (corners(1).Z + corners(5).Z) / 2 + 1 * dirVector.Z
pmiHeight = DimPtToPt(cornerNxPoints(1), cornerNxPoints(5), dimOrigin, "YZ")
pmiHeight.SetUserAttribute("PMI", 1, "Height", Update.Option.Now)
' ZX Dimension 2
Dim pmiLength As PmiParallelDimension = line_links(14).AssociatedObject
dirVector = CreateVector(corners(0), corners(1))
dimOrigin.X = (corners(0).X + corners(3).X) / 2 + 1 * dirVector.X
dimOrigin.Y = (corners(0).Y + corners(3).Y) / 2 + 1 * dirVector.Y
dimOrigin.Z = (corners(0).Z + corners(3).Z) / 2 + 1 * dirVector.Z
pmiLength = DimPtToPt(cornerNxPoints(0), cornerNxPoints(3), dimOrigin, "XZ")
pmiLength.SetUserAttribute("PMI", 2, "Length", Update.Option.Now)
End If
End If
Catch ex As NXException
Echo("Caught Exception in bbUpdateCB: '" & ex.Message() & "'")
End Try
End Function
Private Function CreateVector(ByVal iVecHead As Point3d, ByVal iVecTail As Point3d) As Vector3d
Dim Mag As Double
Mag = Math.Sqrt((iVecHead.X - iVecTail.X) ^ 2 + (iVecHead.Y - iVecTail.Y) ^ 2 + (iVecHead.Z - iVecTail.Z) ^ 2)
Dim Vctr As New Vector3d((iVecHead.X - iVecTail.X) / Mag, (iVecHead.Y - iVecTail.Y) / Mag, (iVecHead.Z - iVecTail.Z) / Mag)
Return Vctr
End Function
Public Function DimPtToPt(ByVal Point1 As Point, ByVal Point2 As Point, ByVal Origin As Point3d, ByVal iPlane As String) As PmiParallelDimension
Dim pmiRapidDimensionBuilder1 As Annotations.PmiRapidDimensionBuilder
pmiRapidDimensionBuilder1 = theSession.Parts.Work.Dimensions.CreatePmiRapidDimensionBuilder(Nothing)
pmiRapidDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)
pmiRapidDimensionBuilder1.Origin.Anchor = Annotations.OriginBuilder.AlignmentPosition.MidCenter
If iPlane = "XY" Then
pmiRapidDimensionBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane
ElseIf iPlane = "YZ" Then
pmiRapidDimensionBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.YzPlane
Else
pmiRapidDimensionBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XzPlane
End If
pmiRapidDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)
Dim nullDirection As Direction = Nothing
pmiRapidDimensionBuilder1.Measurement.Direction = nullDirection
Dim nullView As View = Nothing
pmiRapidDimensionBuilder1.Measurement.DirectionView = nullView
pmiRapidDimensionBuilder1.Style.DimensionStyle.NarrowDisplayType = Annotations.NarrowDisplayOption.None
Dim point1_1 As Point3d = New Point3d(Point1.Coordinates.X, Point1.Coordinates.Y, Point1.Coordinates.Z)
Dim point2_1 As Point3d = New Point3d(0.0, 0.0, 0.0)
pmiRapidDimensionBuilder1.FirstAssociativity.SetValue(InferSnapType.SnapType.Exist, Point1, theSession.Parts.Work.ModelingViews.WorkView, point1_1, Nothing, nullView, point2_1)
Dim objects1(0) As NXObject
objects1(0) = Point1
pmiRapidDimensionBuilder1.AssociatedObjects.Nxobjects.SetArray(objects1)
Dim point1_4 As Point3d = New Point3d(Point2.Coordinates.X, Point2.Coordinates.Y, Point2.Coordinates.Z)
Dim point2_4 As Point3d = New Point3d(0.0, 0.0, 0.0)
pmiRapidDimensionBuilder1.SecondAssociativity.SetValue(InferSnapType.SnapType.Mid, Point2, theSession.Parts.Work.ModelingViews.WorkView, point1_4, Nothing, nullView, point2_4)
Dim objects2(1) As NXObject
objects2(0) = Point1
objects2(1) = Point2
pmiRapidDimensionBuilder1.AssociatedObjects.Nxobjects.SetArray(objects2)
pmiRapidDimensionBuilder1.Origin.Origin.SetValue(Nothing, nullView, Origin)
pmiRapidDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)
pmiRapidDimensionBuilder1.Style.LineArrowStyle.LeaderOrientation = Annotations.LeaderSide.Left
Dim nXObject1 As NXObject
nXObject1 = pmiRapidDimensionBuilder1.Commit()
pmiRapidDimensionBuilder1.Destroy()
Return nXObject1
End Function
Sub mapDirs2Abs(ByVal dirs(,) As Double, ByRef vec() As Double)
Dim absCsys() As Double = {0, 0, 0, 1, 0, 0, 0, 1, 0}
Dim dirsCsys() As Double = {0, 0, 0, dirs(0, 0), dirs(0, 1), dirs(0, 2), dirs(1, 0), dirs(1, 1), dirs(1, 2)}
Dim mx(11) As Double
Dim status As Integer
theUFSession.Trns.CreateCsysMappingMatrix(dirsCsys, absCsys, mx, status)
theUFSession.Trns.MapPosition(vec, mx)
End Sub
Sub mapAbs2Dirs(ByVal dirs(,) As Double, ByRef vec() As Double)
Dim absCsys() As Double = {0, 0, 0, 1, 0, 0, 0, 1, 0}
Dim dirsCsys() As Double = {0, 0, 0, dirs(0, 0), dirs(0, 1), dirs(0, 2), dirs(1, 0), dirs(1, 1), dirs(1, 2)}
Dim mx(11) As Double
Dim status As Integer
theUFSession.Trns.CreateCsysMappingMatrix(absCsys, dirsCsys, mx, status)
theUFSession.Trns.MapPosition(vec, mx)
End Sub
Public Function bbEditCB(ByVal editEvent As UserDefinedEvent) As Integer
Try
bbUdo = editEvent.UserDefinedObject
Show_boundingBox()
Catch ex As NXException
Echo("Caught Exception in bbEditCB: '" & ex.Message() & "'")
End Try
bbEditCB = 0
End Function
Public Function bbInfoCB(ByVal editEvent As UserDefinedEvent) As Integer
Try
bbUdo = editEvent.UserDefinedObject
Dim sizes() As Double = bbUdo.GetLengths()
Echo("Bounding Box is " & sizes(0) & " X " & sizes(1) & " X " & sizes(2) & " " & bbUd

wningPart.PartUnits.ToString)
Echo(" Volume is " & (sizes(0) * sizes(1) * sizes(2)) & " " & bbUd

wningPart.PartUnits.ToString & "^3")
Catch ex As NXException
Echo("Caught Exception in bbEditCB: '" & ex.Message() & "'")
End Try
bbInfoCB = 0
End Function
Public Function initUDO() As Integer
Try
If theSession Is Nothing Then
theSession = Session.GetSession()
theUFSession = NXOpen.UF.UFSession.GetUFSession()
theSession.LogFile.WriteLine("Registering Bounding Box UDO Class")
bbClass = theSession.UserDefinedClassManager.CreateUserDefinedObjectClass("Bounding Box", "Bounding Box")
bbClass.AllowOwnedObjectSelectionOption = UserDefinedClass.AllowOwnedObjectSelection.On
bbClass.AddUpdateHandler(AddressOf bbUpdateCB)
bbClass.AddEditHandler(AddressOf bbEditCB)
bbClass.AddInformationHandler(AddressOf bbInfoCB)
End If
Catch ex As NXException
Echo("Caught Exception in initUDO: '" & ex.Message() & "'" & vbCrLf)
End Try
initUDO = 0
End Function
Sub Main()
Try
initUDO()
Dim workPart As Part = theSession.Parts.Work
If Not workPart Is Nothing Then
bbUdo = workPart.UserDefinedObjectManager.CreateUserDefinedObject(bbClass)
Dim autoTypes() As Integer = {UFConstants.UF_line_type, _
UFConstants.UF_circle_type, _
UFConstants.UF_conic_type, _
UFConstants.UF_spline_type, _
UFConstants.UF_solid_type}
Dim autoSubtypes() As Integer = {0, 0, 0, 0, UFConstants.UF_solid_body_subtype}
Dim selobjs() As DisplayableObject = getAllObjectsByTypesAndSubtypes(autoTypes, autoSubtypes)
If (selobjs.Length < 1) Then Return
Dim links(selobjs.Length - 1) As UserDefinedObject.LinkDefinition
For ii As Integer = 0 To selobjs.Length - 1
links(ii).AssociatedObject = selobjs(ii)
Next
bbUdo.SetLinks(UserDefinedObject.LinkType.Type3, links)
Dim clinks(0) As UserDefinedObject.LinkDefinition
clinks(0).AssociatedObject = theSession.Parts.Work.WCS.CoordinateSystem
bbUdo.SetLinks(UserDefinedObject.LinkType.Type2, clinks)
Dim bbfb As Features.UserDefinedObjectFeatureBuilder = workPart.Features.CreateUserDefinedObjectFeatureBuilder(Nothing)
bbfb.UserDefinedObject = bbUdo
bbfb.Commit()
bbfb.Destroy() ' This is important! See PR 6419778.
Show_boundingBox()
End If
Catch ex As NXException
Echo("Caught Exception in Main: '" & ex.Message() & "'")
End Try
End Sub
Function getAllObjectsByTypesAndSubtypes(ByVal whatTypes() As Integer, ByVal whatSubTypes() As Integer) As DisplayableObject()
Dim objList As ArrayList = New ArrayList
Dim thisType As Integer = 0
Dim thisSubType As Integer = 0
For Each obj As DisplayableObject In theSession.Parts.Work.Views.WorkView.AskVisibleObjects
theUFSession.Obj.AskTypeAndSubtype(obj.Tag, thisType, thisSubType)
For ii As Integer = 0 To whatTypes.Length - 1
If whatTypes(ii) = thisType And whatSubTypes(ii) = thisSubType Then
objList.Add(obj)
End If
Next
Next
Return objList.ToArray(GetType(DisplayableObject))
End Function
Public Function Startup() As Integer
initUDO()
Startup = 0
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return CType(Session.LibraryUnloadOption.Explicitly, Integer)
End Function
Public Class boundingBox
Private Shared theUI As UI
Private theDialogName As String
Private theDialog As NXOpen.BlockStyler.BlockDialog
Private group0 As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private selection0 As NXOpen.BlockStyler.UIBlock ' Block type: Selection
Private coord_system0 As NXOpen.BlockStyler.UIBlock ' Block type: Specify Csys Private DllFileDirectory As String
Private theDlxFileName As String
Public Sub New()
Try
theSession = Session.GetSession()
theUI = UI.GetUI()
Dim DllFileLocation As String
DllFileLocation = System.Reflection.Assembly.GetExecutingAssembly().Location
DllFileDirectory = ""
For i As Integer = 0 To DllFileLocation.Split("\").Length - 2
DllFileDirectory = DllFileDirectory + DllFileLocation.Split("\")(i) + "\"
Next
theDlxFileName = DllFileDirectory + "boundingBox.dlx"
theDialog = theUI.CreateDialog(theDlxFileName)
'theDialogName = "boundingBox.dlx"
'theDialog = theUI.CreateDialog(theDialogName)
theDialog.AddApplyHandler(AddressOf apply_cb)
theDialog.AddOkHandler(AddressOf ok_cb)
theDialog.AddUpdateHandler(AddressOf update_cb)
theDialog.AddInitializeHandler(AddressOf initialize_cb)
theDialog.AddDialogShownHandler(AddressOf dialogShown_cb)
theUI.SelectionManager.SetSelectionStatusOfUserDefinedClass(bbClass, True)
Catch ex As Exception
Echo("Caught Exception in New: '" & ex.Message() & "'" & vbCrLf)
Throw ex
End Try
End Sub
Public Sub Show()
Try
theDialog.Show(BlockDialog.DialogMode.Edit)
Catch ex As Exception
Echo("Caught Exception in Show: '" & ex.Message() & "'" & vbCrLf)
End Try
End Sub
Public Sub Dispose()
If theDialog IsNot Nothing Then
theDialog.Dispose()
theDialog = Nothing
End If
End Sub
Public Sub initialize_cb()
Try
group0 = CType(theDialog.TopBlock.FindBlock("group0"), NXOpen.BlockStyler.UIBlock)
selection0 = CType(theDialog.TopBlock.FindBlock("selection0"), NXOpen.BlockStyler.UIBlock)
coord_system0 = CType(theDialog.TopBlock.FindBlock("coord_system0"), NXOpen.BlockStyler.UIBlock)
Dim selectionFilter(6) As NXOpen.Selection.MaskTriple
With selectionFilter(0)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
End With
With selectionFilter(1)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_FACE
End With
With selectionFilter(2)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE
End With
With selectionFilter(3)
.Type = UFConstants.UF_line_type
.Subtype = 0
.SolidBodySubtype = 0
End With
With selectionFilter(4)
.Type = UFConstants.UF_circle_type
.Subtype = 0
.SolidBodySubtype = 0
End With
With selectionFilter(5)
.Type = UFConstants.UF_conic_type
.Subtype = 0
.SolidBodySubtype = 0
End With
With selectionFilter(6)
.Type = UFConstants.UF_spline_type
.Subtype = 0
.SolidBodySubtype = 0
End With
selection0.GetProperties.SetSelectionFilter("SelectionFilter", Selection.SelectionAction.ClearAndEnableSpecific, selectionFilter)
Dim links() As UserDefinedObject.LinkDefinition = bbUdo.GetLinks(UserDefinedObject.LinkType.Type3)
Dim selObjs(links.Length - 1) As DisplayableObject
For ii As Integer = 0 To links.Length - 1
selObjs(ii) = links(ii).AssociatedObject
selObjs(ii).Highlight()
Next
selection0.GetProperties.SetTaggedObjectVector("SelectedObjects", selObjs)
Dim clinks() As UserDefinedObject.LinkDefinition = bbUdo.GetLinks(UserDefinedObject.LinkType.Type2)
If clinks.Length > 0 Then
Dim csys() As TaggedObject = {clinks(0).AssociatedObject}
coord_system0.GetProperties.SetTaggedObjectVector("SelectedObjects", csys)
End If
Catch ex As Exception
Echo("Caught Exception in dialogShown_cb: '" & ex.Message() & "'" & vbCrLf)
End Try
End Sub
Public Sub dialogShown_cb()
End Sub
Public Function apply_cb() As Integer
Dim errorCode As Integer = 0
Try
Dim objs() As TaggedObject = selection0.GetProperties.GetTaggedObjectVector("SelectedObjects")
Dim links(objs.Length - 1) As UserDefinedObject.LinkDefinition
For ii As Integer = 0 To objs.Length - 1
links(ii).AssociatedObject = objs(ii)
Next
bbUdo.SetLinks(UserDefinedObject.LinkType.Type3, links)
Dim clinks(0) As UserDefinedObject.LinkDefinition
objs = coord_system0.GetProperties.GetTaggedObjectVector("SelectedObjects")
clinks(0).AssociatedObject = objs(0)
bbUdo.SetLinks(UserDefinedObject.LinkType.Type2, clinks)
Dim markId1 As Session.UndoMarkId = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Edit Bounding Box")
Dim nErrs2 As Integer = theSession.UpdateManager.DoUpdate(markId1)
theSession.DeleteUndoMark(markId1, Nothing)
Catch ex As Exception
errorCode = 1
Echo("Caught Exception in apply_cb: '" & ex.Message() & "'" & vbCrLf)
End Try
apply_cb = errorCode
End Function
Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
Try
If block Is selection0 Then
ElseIf block Is coord_system0 Then
End If
Catch ex As Exception
Echo("Caught Exception in update_cb: '" & ex.Message() & "'" & vbCrLf)
End Try
update_cb = 0
End Function
Public Function ok_cb() As Integer
Dim errorCode As Integer = 0
Try
errorCode = apply_cb()
Catch ex As Exception
Echo("Caught Exception in ok_cb: '" & ex.Message() & "'" & vbCrLf)
End Try
ok_cb = errorCode
End Function
End Class
End Module