burgerlord
Mechanical
- Mar 18, 2016
- 4
i found an old thread that has a journal to put a sphere of the specified size on multiple points but when i try to run it in nx9.0 it asks me for the sphere diameter and then it does nothing it acts like it is done running but no spheres are created on the points?
here is the code that i found in the old thread
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI
Module Module1
Dim s As Session = Session.GetSession()
Dim ui As UI = UI.GetUI()
Dim disppart As Part = s.Parts.Display
Sub Main()
Dim pnts As PointCollection = disppart.Points
Dim dia1 As Double = NXInputBox.GetInputNumber("Enter Sphere Diameter")
For Each pnt As Point In pnts
createSphere(pnt, dia1)
Next
End Sub
Public Sub createSphere(ByVal pnt As Point, ByVal dia1 As Double)
Dim nullFeatures_Sphere As Features.Sphere = Nothing
Dim sphereBuilder1 As Features.SphereBuilder
sphereBuilder1 = disppart.Features.CreateSphereBuilder(nullFeatures_Sphere)
sphereBuilder1.CenterPoint = pnt
sphereBuilder1.Diameter.RightHandSide = dia1.ToString
Dim nXObject1 As NXObject
nXObject1 = sphereBuilder1.Commit()
sphereBuilder1.Destroy()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
here is the code that i found in the old thread
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI
Module Module1
Dim s As Session = Session.GetSession()
Dim ui As UI = UI.GetUI()
Dim disppart As Part = s.Parts.Display
Sub Main()
Dim pnts As PointCollection = disppart.Points
Dim dia1 As Double = NXInputBox.GetInputNumber("Enter Sphere Diameter")
For Each pnt As Point In pnts
createSphere(pnt, dia1)
Next
End Sub
Public Sub createSphere(ByVal pnt As Point, ByVal dia1 As Double)
Dim nullFeatures_Sphere As Features.Sphere = Nothing
Dim sphereBuilder1 As Features.SphereBuilder
sphereBuilder1 = disppart.Features.CreateSphereBuilder(nullFeatures_Sphere)
sphereBuilder1.CenterPoint = pnt
sphereBuilder1.Diameter.RightHandSide = dia1.ToString
Dim nXObject1 As NXObject
nXObject1 = sphereBuilder1.Commit()
sphereBuilder1.Destroy()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module