Code:
Imports System
Imports NXOpenModule NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
If workPart Is Nothing Then
Exit Sub
End If
' ----------------------------------------------
' Menü: Ansicht->Visualisierung->Szene...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
Dim scene1 As NXOpen.Display.Scene = Nothing
scene1 = workPart.Views.CreateScene(workPart.ModelingViews.WorkView, False)
Dim background1 As NXOpen.Display.Background = Nothing
background1 = workPart.Views.CreateBackground(workPart.ModelingViews.WorkView, False)
Dim image1 As NXOpen.Display.Image = Nothing
image1 = workPart.Views.CreateImage(workPart.ModelingViews.WorkView)
Dim image2 As NXOpen.Display.Image = Nothing
image2 = workPart.Views.CreateImage(workPart.ModelingViews.WorkView)
background1.Image = image1
Dim coordinates1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim point1 As NXOpen.Point = Nothing
point1 = workPart.Points.CreatePoint(coordinates1)
background1.DomeOrigin = point1
background1.DomeImage = image2
background1.DomeImageFilename = "C:\plm\nx1899\ugphoto\system_scene_data_dir\Congress_Hall_Full_Saturation.hdr"
background1.BackgroundShadedViewsType = 2
background1.BackgroundWireframeViewsType = 2
Dim lighting1 As NXOpen.Display.Lighting = Nothing
lighting1 = workPart.Views.CreateLighting(workPart.ModelingViews.WorkView)
Dim light1 As NXOpen.Light = CType(workPart.Lights.FindObject("Scene Ambient"), NXOpen.Light)
Dim lightBuilder1 As NXOpen.Display.LightBuilder = Nothing
lightBuilder1 = workPart.Views.CreateLightBuilder(light1)
lighting1.SetLightBuilderInList(0, lightBuilder1)
Dim light2 As NXOpen.Light = CType(workPart.Lights.FindObject("Scene Left Top"), NXOpen.Light)
Dim lightBuilder2 As NXOpen.Display.LightBuilder = Nothing
lightBuilder2 = workPart.Views.CreateLightBuilder(light2)
lighting1.SetLightBuilderInList(1, lightBuilder2)
Dim light3 As NXOpen.Light = CType(workPart.Lights.FindObject("Scene Right Top"), NXOpen.Light)
Dim lightBuilder3 As NXOpen.Display.LightBuilder = Nothing
lightBuilder3 = workPart.Views.CreateLightBuilder(light3)
lighting1.SetLightBuilderInList(2, lightBuilder3)
Dim light4 As NXOpen.Light = CType(workPart.Lights.FindObject("Scene Left Bottom"), NXOpen.Light)
Dim lightBuilder4 As NXOpen.Display.LightBuilder = Nothing
lightBuilder4 = workPart.Views.CreateLightBuilder(light4)
lighting1.SetLightBuilderInList(3, lightBuilder4)
Dim light5 As NXOpen.Light = CType(workPart.Lights.FindObject("Scene Right Bottom"), NXOpen.Light)
Dim lightBuilder5 As NXOpen.Display.LightBuilder = Nothing
lightBuilder5 = workPart.Views.CreateLightBuilder(light5)
lighting1.SetLightBuilderInList(4, lightBuilder5)
lighting1.LightsShadedViewsLightingCollection = NXOpen.Display.Lighting.LightingCollectionType.UserDefined
Dim environmentBuilder1 As NXOpen.Display.EnvironmentBuilder = Nothing
environmentBuilder1 = workPart.Views.CreateEnvironmentBuilder(workPart.ModelingViews.WorkView, False)
Dim origin1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim normal1 As NXOpen.Vector3d = New NXOpen.Vector3d(0.0, 0.0, 1.0)
Dim plane1 As NXOpen.Plane = Nothing
plane1 = workPart.Planes.CreatePlane(origin1, normal1, NXOpen.SmartObject.UpdateOption.AfterModeling)
Dim unit1 As NXOpen.Unit = Nothing
unit1 = environmentBuilder1.SizeExpression.Units
Dim expression1 As NXOpen.Expression = Nothing
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression2 As NXOpen.Expression = Nothing
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim image3 As NXOpen.Display.Image = Nothing
image3 = workPart.Views.CreateImage(workPart.ModelingViews.WorkView)
environmentBuilder1.SpecifyGroundPlane = plane1
Dim origin2 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim normal2 As NXOpen.Vector3d = New NXOpen.Vector3d(0.0, 0.0, 1.0)
Dim plane2 As NXOpen.Plane = Nothing
plane2 = workPart.Planes.CreatePlane(origin2, normal2, NXOpen.SmartObject.UpdateOption.WithinModeling)
environmentBuilder1.EnvironmentShadedViewsGroundPlaneCustom = plane2
Dim expression3 As NXOpen.Expression = Nothing
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression4 As NXOpen.Expression = Nothing
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
environmentBuilder1.Image = image3
environmentBuilder1.ImageFilename = "C:\plm\nx1899\ugphoto\system_scene_data_dir\Congress_Hall_Full_Saturation.hdr"
environmentBuilder1.ViewFitToStage = True
environmentBuilder1.EnvironmentShadedViewsGlobalFinish = 3
environmentBuilder1.EnvironmentShadedViewsGroundPlane = 2
Dim shadows1 As NXOpen.Display.Shadows = Nothing
shadows1 = workPart.Views.CreateShadows(workPart.ModelingViews.WorkView)
Dim selectNXObjectList1 As NXOpen.SelectNXObjectList = Nothing
selectNXObjectList1 = shadows1.ShadowCatcherSelection
selectNXObjectList1.Clear()
theSession.SetUndoMarkName(markId1, "Szenenvoreinstellungen-Dialogfenster")
Dim topcolor1(2) As Double
topcolor1(0) = 0.12156862745098039
topcolor1(1) = 0.17254901960784313
topcolor1(2) = 0.31764705882352939
background1.SetBackgroundShadedViewsGraduatedTop(topcolor1)
Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = background1.Commit()
Dim bottomcolor1(2) As Double
bottomcolor1(0) = 0.40392156862745099
bottomcolor1(1) = 0.58039215686274515
bottomcolor1(2) = 0.77254901960784317
background1.SetBackgroundShadedViewsGraduatedBottom(bottomcolor1)
Dim nXObject2 As NXOpen.NXObject = Nothing
nXObject2 = background1.Commit()
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Szenenvoreinstellungen")
theSession.DeleteUndoMark(markId2, Nothing)
Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Szenenvoreinstellungen")
Dim nXObject3 As NXOpen.NXObject = Nothing
nXObject3 = scene1.Commit()
theSession.DeleteUndoMark(markId3, Nothing)
theSession.SetUndoMarkName(markId1, "Szenenvoreinstellungen")
scene1.Destroy()
background1.Destroy()
lighting1.Destroy()
environmentBuilder1.Destroy()
shadows1.Destroy()
Try
' Ausdruck wird immer noch verwendet.
workPart.Expressions.Delete(expression2)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try
Try
' Ausdruck wird immer noch verwendet.
workPart.Expressions.Delete(expression4)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try
Try
' Ausdruck wird immer noch verwendet.
workPart.Expressions.Delete(expression1)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try
plane1.DestroyPlane()
Try
' Ausdruck wird immer noch verwendet.
workPart.Expressions.Delete(expression3)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try
plane2.DestroyPlane()
theSession.CleanUpFacetedFacesAndEdges()
End Sub
Public Function GetUnloadOption(ByVal arg As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module