Option Infer On Option Strict Off Imports Snap, Snap.Create Imports NXOpenUI Imports System Imports NXOpen Imports Snap.UI Imports Snap.NX Imports NXOpen.BlockStyler Public Module HeadImpact Dim theSession As NXOpen.Session = Session.GetSession() Dim workpart As NXOpen.Part = theSession.Parts.Work Dim displayPart As NXOpen.Part = theSession.Parts.Display Dim theUI As UI = UI.GetUI Public Class Wizard 'class members Private Shared theSession As Session Private Shared theUI As UI Private theDlxFileName As String Private theDialog As NXOpen.BlockStyler.BlockDialog Private wizard As NXOpen.BlockStyler.Wizard ' Block type: Wizard Private wizardStep6 As NXOpen.BlockStyler.Group ' Block type: Group Private group As NXOpen.BlockStyler.Group ' Block type: Group Private label01 As NXOpen.BlockStyler.Label ' Block type: Label Private label02 As NXOpen.BlockStyler.Label ' Block type: Label Private label03 As NXOpen.BlockStyler.Label ' Block type: Label Private label04 As NXOpen.BlockStyler.Label ' Block type: Label Private wizardStep7 As NXOpen.BlockStyler.Group ' Block type: Group Private group1 As NXOpen.BlockStyler.Group ' Block type: Group Private label06 As NXOpen.BlockStyler.Label ' Block type: Label Private label07 As NXOpen.BlockStyler.Label ' Block type: Label Private label08 As NXOpen.BlockStyler.Label ' Block type: Label Private label09 As NXOpen.BlockStyler.Label ' Block type: Label Private label010 As NXOpen.BlockStyler.Label ' Block type: Label Private label011 As NXOpen.BlockStyler.Label ' Block type: Label Private wizardStep1 As NXOpen.BlockStyler.Group ' Block type: Group Private double0 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private double01 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private double02 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private double08 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private double03 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private double04 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private label05 As NXOpen.BlockStyler.Label ' Block type: Label Private button0 As NXOpen.BlockStyler.Button ' Block type: Button Private wizardStep2 As NXOpen.BlockStyler.Group ' Block type: Group Private double06 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private double07 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private double09 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double Private linear_dim0 As NXOpen.BlockStyler.LinearDimension ' Block type: Linear Dim Private angular_dim0 As NXOpen.BlockStyler.AngularDimension ' Block type: Angular Dim Private label051 As NXOpen.BlockStyler.Label ' Block type: Label Private button01 As NXOpen.BlockStyler.Button ' Block type: Button Private wizardStep As NXOpen.BlockStyler.Group ' Block type: Group Private selection0 As NXOpen.BlockStyler.SelectObject ' Block type: Selection 'Private bodySelect0 As NXOpen.BlockStyler.SelectObject ' Block type: Body Collector Private wizardStep5 As NXOpen.BlockStyler.Group ' Block type: Group Private enum0 As NXOpen.BlockStyler.Enumeration ' Block type: Enumeration Private enum01 As NXOpen.BlockStyler.Enumeration ' Block type: Enumeration Private wizardStep3 As NXOpen.BlockStyler.Group ' Block type: Group Private label0 As NXOpen.BlockStyler.Label ' Block type: Label Private angular_dim01 As NXOpen.BlockStyler.AngularDimension ' Block type: Angular Dim Private angular_dim02 As NXOpen.BlockStyler.AngularDimension ' Block type: Angular Dim Private wizardStep8 As NXOpen.BlockStyler.Group ' Block type: Group Private button02 As NXOpen.BlockStyler.Button ' Block type: Button Private button05 As NXOpen.BlockStyler.Button ' Block type: Button Private button06 As NXOpen.BlockStyler.Button ' Block type: Button '------------------------------------------------------------------------------ 'Bit Option for Property: SnapPointTypesOnByDefault '------------------------------------------------------------------------------ Public Shared ReadOnly SnapPointTypesOnByDefault_UserDefined As Integer = 1 Public Shared ReadOnly SnapPointTypesOnByDefault_Inferred As Integer = 2 Public Shared ReadOnly SnapPointTypesOnByDefault_ScreenPosition As Integer = 4 Public Shared ReadOnly SnapPointTypesOnByDefault_EndPoint As Integer = 8 Public Shared ReadOnly SnapPointTypesOnByDefault_MidPoint As Integer = 16 Public Shared ReadOnly SnapPointTypesOnByDefault_ControlPoint As Integer = 32 Public Shared ReadOnly SnapPointTypesOnByDefault_Intersection As Integer = 64 Public Shared ReadOnly SnapPointTypesOnByDefault_ArcCenter As Integer = 128 Public Shared ReadOnly SnapPointTypesOnByDefault_QuadrantPoint As Integer = 256 Public Shared ReadOnly SnapPointTypesOnByDefault_ExistingPoint As Integer = 512 Public Shared ReadOnly SnapPointTypesOnByDefault_PointonCurve As Integer = 1024 Public Shared ReadOnly SnapPointTypesOnByDefault_PointonSurface As Integer = 2048 Public Shared ReadOnly SnapPointTypesOnByDefault_PointConstructor As Integer = 4096 Public Shared ReadOnly SnapPointTypesOnByDefault_TwocurveIntersection As Integer = 8192 Public Shared ReadOnly SnapPointTypesOnByDefault_TangentPoint As Integer = 16384 Public Shared ReadOnly SnapPointTypesOnByDefault_Poles As Integer = 32768 Public Shared ReadOnly SnapPointTypesOnByDefault_BoundedGridPoint As Integer = 65536 '------------------------------------------------------------------------------ 'Bit Option for Property: EntityType '------------------------------------------------------------------------------ Public Shared ReadOnly EntityType_AllowBodies As Integer = 64 '------------------------------------------------------------------------------ 'Bit Option for Property: BodyRules '------------------------------------------------------------------------------ Public Shared ReadOnly BodyRules_SingleBody As Integer = 1 Public Shared ReadOnly BodyRules_FeatureBodies As Integer = 2 Public Shared ReadOnly BodyRules_BodiesinGroup As Integer = 4 #Region "Block Styler Dialog Designer generator code" '------------------------------------------------------------------------------ 'Constructor for NX Styler class '------------------------------------------------------------------------------ Public Sub New() Try theSession = Session.GetSession() theUI = UI.GetUI() theDlxFileName = "C:\Users\Sun\Desktop\Wizard.dlx" theDialog = theUI.CreateDialog(theDlxFileName) 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) Catch ex As Exception '---- Enter your exception handling code here ----- Throw ex End Try End Sub #End Region '------------------------------- DIALOG LAUNCHING --------------------------------- ' ' Before invoking this application one needs to open any part/empty part in NX ' because of the behavior of the blocks. ' ' Make sure the dlx file is in one of the following locations: ' 1.) From where NX session is launched ' 2.) $UGII_USER_DIR/application ' 3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly ' recommended. This variable is set to a full directory path to a file ' containing a list of root directories for all custom applications. ' e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat ' ' You can create the dialog using one of the following way: ' ' 1. Journal Replay ' ' 1) Replay this file through Tool->Journal->Play Menu. ' ' 2. USER EXIT ' ' 1) Create the Shared Library -- Refer "Block UI Styler programmer's guide" ' 2) Invoke the Shared Library through File->Execute->NX Open menu. ' '------------------------------------------------------------------------------ Public Shared Sub Main() Dim theWizard As Wizard = Nothing Try theWizard = New Wizard() theWizard.Show() Catch ex As Exception '---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) Finally If theWizard IsNot Nothing Then theWizard.Dispose() theWizard = Nothing End If End Try End Sub '------------------------------------------------------------------------------ ' This method specifies how a shared image is unloaded from memory ' within NX. This method gives you the capability to unload an ' internal NX Open application or user exit from NX. Specify any ' one of the three constants as a return value to determine the type ' of unload to perform: ' ' ' Immediately : unload the library as soon as the automation program has completed ' Explicitly : unload the library from the "Unload Shared Image" dialog ' AtTermination : unload the library when the NX session terminates ' ' ' NOTE: A program which associates NX Open applications with the menubar ' MUST NOT use this option since it will UNLOAD your NX Open application image ' from the menubar. '------------------------------------------------------------------------------ Public Shared Function GetUnloadOption(ByVal arg As String) As Integer 'Return CType(Session.LibraryUnloadOption.Explicitly, Integer) Return CType(Session.LibraryUnloadOption.Immediately, Integer) ' Return CType(Session.LibraryUnloadOption.AtTermination, Integer) End Function Public Shared Sub UnloadLibrary(ByVal arg As String) Try Catch ex As Exception '---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) End Try End Sub '------------------------------------------------------------------------------ 'This method shows the dialog on the screen '------------------------------------------------------------------------------ Public Sub Show() Try theDialog.Show() Catch ex As Exception '---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) End Try End Sub '------------------------------------------------------------------------------ 'Method Name: Dispose '------------------------------------------------------------------------------ Public Sub Dispose() If theDialog IsNot Nothing Then theDialog.Dispose() theDialog = Nothing End If End Sub '------------------------------------------------------------------------------ '---------------------Block UI Styler Callback Functions-------------------------- '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ 'Callback Name: initialize_cb '------------------------------------------------------------------------------ Public Sub initialize_cb() Try wizard = CType(theDialog.TopBlock.FindBlock("wizard"), NXOpen.BlockStyler.Wizard) wizardStep6 = CType(theDialog.TopBlock.FindBlock("wizardStep6"), NXOpen.BlockStyler.Group) group = CType(theDialog.TopBlock.FindBlock("group"), NXOpen.BlockStyler.Group) label01 = CType(theDialog.TopBlock.FindBlock("label01"), NXOpen.BlockStyler.Label) label02 = CType(theDialog.TopBlock.FindBlock("label02"), NXOpen.BlockStyler.Label) label03 = CType(theDialog.TopBlock.FindBlock("label03"), NXOpen.BlockStyler.Label) label04 = CType(theDialog.TopBlock.FindBlock("label04"), NXOpen.BlockStyler.Label) wizardStep7 = CType(theDialog.TopBlock.FindBlock("wizardStep7"), NXOpen.BlockStyler.Group) group1 = CType(theDialog.TopBlock.FindBlock("group1"), NXOpen.BlockStyler.Group) label06 = CType(theDialog.TopBlock.FindBlock("label06"), NXOpen.BlockStyler.Label) label07 = CType(theDialog.TopBlock.FindBlock("label07"), NXOpen.BlockStyler.Label) label08 = CType(theDialog.TopBlock.FindBlock("label08"), NXOpen.BlockStyler.Label) label09 = CType(theDialog.TopBlock.FindBlock("label09"), NXOpen.BlockStyler.Label) label010 = CType(theDialog.TopBlock.FindBlock("label010"), NXOpen.BlockStyler.Label) label011 = CType(theDialog.TopBlock.FindBlock("label011"), NXOpen.BlockStyler.Label) wizardStep1 = CType(theDialog.TopBlock.FindBlock("wizardStep1"), NXOpen.BlockStyler.Group) double0 = CType(theDialog.TopBlock.FindBlock("double0"), NXOpen.BlockStyler.DoubleBlock) double01 = CType(theDialog.TopBlock.FindBlock("double01"), NXOpen.BlockStyler.DoubleBlock) double02 = CType(theDialog.TopBlock.FindBlock("double02"), NXOpen.BlockStyler.DoubleBlock) double08 = CType(theDialog.TopBlock.FindBlock("double08"), NXOpen.BlockStyler.DoubleBlock) double03 = CType(theDialog.TopBlock.FindBlock("double03"), NXOpen.BlockStyler.DoubleBlock) double04 = CType(theDialog.TopBlock.FindBlock("double04"), NXOpen.BlockStyler.DoubleBlock) label05 = CType(theDialog.TopBlock.FindBlock("label05"), NXOpen.BlockStyler.Label) button0 = CType(theDialog.TopBlock.FindBlock("button0"), NXOpen.BlockStyler.Button) wizardStep2 = CType(theDialog.TopBlock.FindBlock("wizardStep2"), NXOpen.BlockStyler.Group) double06 = CType(theDialog.TopBlock.FindBlock("double06"), NXOpen.BlockStyler.DoubleBlock) double07 = CType(theDialog.TopBlock.FindBlock("double07"), NXOpen.BlockStyler.DoubleBlock) double09 = CType(theDialog.TopBlock.FindBlock("double09"), NXOpen.BlockStyler.DoubleBlock) linear_dim0 = CType(theDialog.TopBlock.FindBlock("linear_dim0"), NXOpen.BlockStyler.LinearDimension) angular_dim0 = CType(theDialog.TopBlock.FindBlock("angular_dim0"), NXOpen.BlockStyler.AngularDimension) label051 = CType(theDialog.TopBlock.FindBlock("label051"), NXOpen.BlockStyler.Label) button01 = CType(theDialog.TopBlock.FindBlock("button01"), NXOpen.BlockStyler.Button) wizardStep = CType(theDialog.TopBlock.FindBlock("wizardStep"), NXOpen.BlockStyler.Group) selection0 = CType(theDialog.TopBlock.FindBlock("selection0"), NXOpen.BlockStyler.SelectObject) wizardStep5 = CType(theDialog.TopBlock.FindBlock("wizardStep5"), NXOpen.BlockStyler.Group) enum0 = CType(theDialog.TopBlock.FindBlock("enum0"), NXOpen.BlockStyler.Enumeration) enum01 = CType(theDialog.TopBlock.FindBlock("enum01"), NXOpen.BlockStyler.Enumeration) wizardStep3 = CType(theDialog.TopBlock.FindBlock("wizardStep3"), NXOpen.BlockStyler.Group) label0 = CType(theDialog.TopBlock.FindBlock("label0"), NXOpen.BlockStyler.Label) angular_dim01 = CType(theDialog.TopBlock.FindBlock("angular_dim01"), NXOpen.BlockStyler.AngularDimension) angular_dim02 = CType(theDialog.TopBlock.FindBlock("angular_dim02"), NXOpen.BlockStyler.AngularDimension) wizardStep8 = CType(theDialog.TopBlock.FindBlock("wizardStep8"), NXOpen.BlockStyler.Group) button02 = CType(theDialog.TopBlock.FindBlock("button02"), NXOpen.BlockStyler.Button) button05 = CType(theDialog.TopBlock.FindBlock("button05"), NXOpen.BlockStyler.Button) button06 = CType(theDialog.TopBlock.FindBlock("button06"), NXOpen.BlockStyler.Button) '------------------------------------------------------------------------------ 'Registration of Wizard specific callbacks '------------------------------------------------------------------------------ 'wizard.SetStepNotifyPreHandler(AddressOf StepNotifyPreCallback) 'wizard.SetStepNotifyPostHandler(AddressOf StepNotifyPostCallback) 'wizard.SetIsStepOkayHandler(AddressOf IsStepOkayCallback) 'wizard.SetOnSubNodeHandler(AddressOf OnSubNodeCallback) 'wizard.SetOnMenuHandler(AddressOf OnMenuCallback) 'wizard.SetOnMenuSelectionHandler(AddressOf OnMenuSelectionCallback) Catch ex As Exception '---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) End Try End Sub '------------------------------------------------------------------------------ 'Callback Name: dialogShown_cb 'This callback is executed just before the dialog launch. Thus any value set 'here will take precedence and dialog will be launched showing that value. '------------------------------------------------------------------------------ Public Sub dialogShown_cb() Try Catch ex As Exception '---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) End Try End Sub '------------------------------------------------------------------------------ 'Callback Name: apply_cb '------------------------------------------------------------------------------ Public Function apply_cb() As Integer Dim errorCode As Integer = 0 Try Catch ex As Exception '---- Enter your exception handling code here ----- errorCode = 1 theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) End Try apply_cb = errorCode End Function '------------------------------------------------------------------------------ 'Callback Name: update_cb '------------------------------------------------------------------------------ Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer Try If block Is double0 Then Dim whlx As String = double0.Value Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp1 As NX.Expression = CType(workpart.Expressions.FindObject("HLx"), NX.Expression) workpart.Expressions.Edit(exp1, whlx) ElseIf block Is double01 Then Dim whly As String = double01.Value Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp2 As NX.Expression = CType(workpart.Expressions.FindObject("HLy"), NX.Expression) workpart.Expressions.Edit(exp2, whly) ElseIf block Is double02 Then Dim whlz As String = double02.Value Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp3 As NX.Expression = CType(workpart.Expressions.FindObject("HLz"), NX.Expression) workpart.Expressions.Edit(exp3, whlz) ElseIf block Is double08 Then Dim whrx As String = double08.Value Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp4 As NX.Expression = CType(workpart.Expressions.FindObject("HRx"), NX.Expression) workpart.Expressions.Edit(exp4, whrx) ElseIf block Is double03 Then Dim whry As String = double03.Value Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp5 As NX.Expression = CType(workpart.Expressions.FindObject("HRy"), NX.Expression) workpart.Expressions.Edit(exp5, whry) ElseIf block Is double04 Then Dim whrz As String = double04.Value Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp6 As NX.Expression = CType(workpart.Expressions.FindObject("HRz"), NX.Expression) workpart.Expressions.Edit(exp6, whrz) ElseIf block Is button0 Then Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim nErrs1 As Integer nErrs1 = theSession.UpdateManager.DoUpdate(markId1) ElseIf block Is double06 Then Dim wlrx As String = double06.Value Dim markId2 As Session.UndoMarkId markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp7 As NX.Expression = CType(workpart.Expressions.FindObject("LRx"), NX.Expression) workpart.Expressions.Edit(exp7, wlrx) ElseIf block Is double07 Then Dim wlry As String = double07.Value Dim markId2 As Session.UndoMarkId markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp8 As NX.Expression = CType(workpart.Expressions.FindObject("LRy"), NX.Expression) workpart.Expressions.Edit(exp8, wlry) ElseIf block Is double09 Then Dim wlrz As String = double09.Value Dim markId2 As Session.UndoMarkId markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp9 As NX.Expression = CType(workpart.Expressions.FindObject("LRz"), NX.Expression) workpart.Expressions.Edit(exp9, wlrz) ElseIf block Is linear_dim0 Then Dim wld As String = linear_dim0.Value Dim markId2 As Session.UndoMarkId markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp10 As NX.Expression = CType(workpart.Expressions.FindObject("Lenkraddurchmesser"), NX.Expression) workpart.Expressions.Edit(exp10, wld) ElseIf block Is angular_dim0 Then Dim wla As String = angular_dim0.Value Dim markId2 As Session.UndoMarkId markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim exp11 As NX.Expression = CType(workpart.Expressions.FindObject("Lenkradneigung"), NX.Expression) workpart.Expressions.Edit(exp11, wla) ElseIf block Is button01 Then Dim markId2 As Session.UndoMarkId markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim nErrs2 As Integer nErrs2 = theSession.UpdateManager.DoUpdate(markId2) ElseIf block Is selection0 Then '######################################################################################################## ElseIf block Is enum0 Then ElseIf block Is enum01 Then ElseIf block Is angular_dim01 Then ElseIf block Is angular_dim02 Then ElseIf block Is button02 Then InfoWindow.WriteLine("blablabla") ElseIf block Is button05 Then Dim expA As NXOpen.Expression = CType(workpart.Expressions.FindObject("Drehwinkel_Schnittebene"), NXOpen.Expression) Dim expK As NXOpen.Expression = CType(workpart.Expressions.FindObject("Kugeldurchmesser"), NXOpen.Expression) Dim markIdA As NXOpen.Session.UndoMarkId Dim nErrsA As Integer Dim WertA As Single workpart.Expressions.Edit(expA, "0") Dim nErrs0 As Integer nErrs0 = theSession.UpdateManager.DoUpdate(0) Dim rStep As Single If block Is enum0 Then rStep = 3 End If Dim pl As PropertyList = enum0.GetProperties() Dim cho1 As Integer If cho1 = pl.GetEnumAsString("1deg") Then rStep = -1 ElseIf cho1 = pl.GetEnumAsString("3deg") Then rStep = -3 ElseIf cho1 = pl.GetEnumAsString("5deg") Then rStep = -5 End If Dim count As Single Dim pl2 As PropertyList = enum01.GetProperties() Dim cho2 As Integer If cho2 = pl2.GetEnumAsString("High") Then count = 600 ElseIf cho2 = pl2.GetEnumAsString("Middle") Then count = 500 ElseIf cho2 = pl2.GetEnumAsString("Low") Then count = 400 End If Dim angleL As Single = angular_dim02.Value.ToString Dim angleR As Single = angular_dim01.Value.ToString For WertA = angleL To -angleR Step -rStep workpart.Expressions.Edit(expA, WertA) nErrsA = theSession.UpdateManager.DoUpdate(markIdA) Dim sketch1 As Sketch = CType(workpart.Sketches.FindObject("SKETCH_003"), Sketch) Dim arcPL2max As NXOpen.Arc = CType(sketch1.FindObject("Curve Arc16"), NXOpen.Arc) Dim path As Snap.NX.Arc = arcPL2max 'Dim body1 As Snap.NX.Body = CType(workpart.Bodies.FindObject("EXTRACT_BODY(101)"), Snap.NX.Body) 'Dim target As Snap.NX.Body = body1 'mit dieser Auswahl funktioniert das Tool '################################################################################# Dim tagobj As NXOpen.TaggedObject() = selection0.GetSelectedObjects() Dim n As Integer = tagobj.Length Dim i As Integer Dim target(n) As NX.Body For i = 1 To n - 1 target(i) = Snap.NX.Body.Wrap(tagobj(i).Tag) Next '################################################################################# Dim diam As Double = expK.Value ' Diameter of sphere Dim radius = diam / 2 Dim minU = path.MinU Dim maxU = path.MaxU Dim stepU = (maxU - minU) / Count For u = minU To maxU Step stepU Dim center = path.Position(u) ' Point on path Dim dist = Compute.Distance(center, target(i)) ' Distance to target If dist < radius + 2 Then Dim sph = Snap.Create.Sphere(center, diam) Dim res As Compute.DistanceResult = Compute.ClosestPoints(sph.Body, target(i)) Dim poi As NX.Point = Snap.Create.Point(res.Point2) sph.Delete() Dim pfb1 As Features.PointFeatureBuilder Dim nullpt As Features.Feature = Nothing pfb1 = workpart.BaseFeatures.CreatePointFeatureBuilder(nullpt) Dim pt1 As NXOpen.Point3d = poi.Position pfb1.Point = poi Dim poi1 As NX.NXObject poi1 = pfb1.Commit() pfb1.Destroy() Exit For End If Next Next theSession.DeleteUndoMark(markIdA, "Update Expression Data") ElseIf block Is button06 Then End If Catch ex As Exception '---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) End Try update_cb = 0 End Function '------------------------------------------------------------------------------ 'Callback Name: ok_cb '------------------------------------------------------------------------------ Public Function ok_cb() As Integer Dim errorCode As Integer = 0 Try '---- Enter your callback code here ----- errorCode = apply_cb() Catch ex As Exception '---- Enter your exception handling code here ----- errorCode = 1 theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) End Try ok_cb = errorCode End Function Public Function GetBlockProperties(ByVal blockID As String) As PropertyList GetBlockProperties = Nothing Try GetBlockProperties = theDialog.GetBlockProperties(blockID) Catch ex As Exception '---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString) End Try End Function End Class End Module