Sample NX Open .NET Visual Basic program : move selected drawing member view
작성자k2ice작성시간09.09.05조회수237 목록 댓글 0Date: 27-FEB-2009
Subject: Sample NX Open .NET Visual Basic program : move selected drawing member view
Note: GTAC provides programming examples for illustration only, and
assumes that you are familiar with the programming language being
demonstrated and the tools used to create and debug procedures. GTAC
support professionals can help explain the functionality of a particular
procedure, but we will not modify these examples to provide added
functionality or construct procedures to meet your specific needs.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.NXObject
Imports NXOpen.Drawings
Module journal
Sub Main()
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow = s.ListingWindow
lw.Open()
Dim dispPart As Part = s.Parts.Display
Dim mView As DraftingView = Nothing
Dim dwgRef As Point3d = Nothing
Dim xy() As String = {"X Direction", "Y Direction"}
Dim which As Integer = 1
Dim howFar As Double = 1.0
Dim borders(3) As Double
ufs.Ui.SetCursorView(0) ' 0 = Any view including drawing views
While select_a_view("Move View", mView) = Selection.Response.Ok
ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
which = ufs.Ui.DisplayMenu("Move in", which, xy, 2) - 4
ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
If which = 1 Or which = 2 Then
howFar = NXInputBox.GetInputNumber("How far?")
dwgRef = mView.GetDrawingReferencePoint()
ufs.Draw.AskViewBorders(mView.Tag, borders)
lw.WriteLine("Moving " & mView.Name() & " from " & _
dwgRef.X.ToString("F3") & ", " & _
dwgRef.Y.ToString("F3") & ", " & _
dwgRef.Z.ToString("F3") & " (" & _
borders(0).ToString("F3") & ", " & _
borders(1).ToString("F3") & ", " & _
borders(2).ToString("F3") & ", " & _
borders(3).ToString("F3") & ")")
If which = 1 Then
dwgRef.X = dwgRef.X + howFar
Else
dwgRef.X = dwgRef.X
End If
If which = 2 Then
dwgRef.Y = dwgRef.Y + howFar
Else
dwgRef.Y = dwgRef.Y
End If
dwgRef.Z = dwgRef.Z
mView.MoveView(dwgRef)
dwgRef = mView.GetDrawingReferencePoint()
ufs.Draw.AskViewBorders(mView.Tag, borders)
lw.WriteLine("Moved " & mView.Name() & " to " & _
dwgRef.X.ToString("F3") & ", " & _
dwgRef.Y.ToString("F3") & ", " & _
dwgRef.Z.ToString("F3") & " (" & _
borders(0).ToString("F3") & ", " & _
borders(1).ToString("F3") & ", " & _
borders(2).ToString("F3") & ", " & _
borders(3).ToString("F3") & ")")
End If
End While
End Sub
Function select_a_view(ByVal Prompt As String, ByRef selview As View) _
As Selection.Response
Dim theUI As UI = UI.GetUI
Dim cursor As Point3d
Dim mask(0) As Selection.MaskTriple
With mask(0)
.Type = UFConstants.UF_view_type
.Subtype = 0
.SolidBodySubtype = 0
End With
Dim resp As Selection.Response = _
theUI.SelectionManager.SelectObject( _
"Select a View", Prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, mask, selview, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module
다음검색