Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Drawings
'Imports NXOpen.Assemblies
'Imports NXOpen.PDM
'Imports System.Collections
'Imports System.Collections.Generic
Imports NXOpen.Annotations
Imports System.Text
Imports NXOpen.Utilities
'Imports System.Text.RegularExpressions
'Imports System.Diagnostics
'Imports NXOpen.Routing
'Imports NXOpen.Features
Module Lkl_Summary_TabNote
Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim ufs As UFSession = UFSession.GetUFSession()
Dim output_To_NXListingWindow As Boolean = True
Dim output_To_NXLogFile As Boolean = True
Sub Main()
ufs.Ui.ExitListingWindow() ' close windows before displaying it again
'START HERE
Report_Object()
End Sub
'=========================== NX LISTING WINDOW FUNCTION=======================================
Public Sub NX(ByVal input As String) '' output variable listwindow - just for building VB
If output_To_NXListingWindow Then
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow()
lw.Open()
lw.WriteLine(input)
End If
End Sub
'===============================================================================================
'=========================== NX WRITE TO LOGFILE FUNCTION=======================================
Public Sub NX_log(ByVal input As String) '' output variable listwindow - just for building VB
If output_To_NXLogFile Then
theSession.LogFile.WriteLine(input)
End If
End Sub
'================================================================================================
'=========================== NX UNLOAD FUNCTION ================================================
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination ' typically used in Checkmate only
End Function
'================================================================================================
'====================================== SELECTION MASK ========================================
Function select_a_DraftingEntity(ByVal prompt As String, ByRef TagOfDrfEntity As DisplayableObject, ByRef cursor As Point3d)
'-------------------------------------------------------------------------------------------------------
' Start define type Mask......Lets define which drafting entities to be able to select...
'how may Drafting entities to select....
Dim mask(5) As Selection.MaskTriple
'Dimension > PerpendicularDimension: Type:26, SubType: 5
'HorizontalDimension: Type:26, SubType: 1
With mask(0)
.Type = UFConstants.UF_dimension_type
.Subtype = 0
.SolidBodySubtype = 0
End With
'DraftingFcf > Type:25, SubType: 4
'DraftingDatum > Type:25, SubType: 4
With mask(1)
.Type = UFConstants.UF_drafting_entity_type '25
.Subtype = 4
.SolidBodySubtype = 0
End With
'LineWeld > Type:25, SubType: 2
With mask(2)
.Type = UFConstants.UF_drafting_entity_type '25
.Subtype = 2
.SolidBodySubtype = 0
End With
'DraftingSurfaceFinish > Type:158, SubType: 2
With mask(3)
.Type = 158
.Subtype = 2
.SolidBodySubtype = 0
End With
'IdSymbol > Type: 25, SubType: 3
With mask(4)
.Type = 25
.Subtype = 3
.SolidBodySubtype = 0
End With
'CustomSymbol > Type: 25, SubType: 30
With mask(5)
.Type = 25
.Subtype = 10
.SolidBodySubtype = 0
End With
'
' End of type Mask......
'-------------------------------------------------------------------------------------------------------
Dim resp As Selection.Response =
theUI.SelectionManager.SelectTaggedObject(prompt, prompt,
Selection.SelectionScope.AnyInAssembly,
Selection.SelectionAction.ClearAndEnableSpecific,
False, False, mask, TagOfDrfEntity, 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 Sub Report_Object()
Dim cursor As Point3d = Nothing
Dim draftingEntity As DisplayableObject = Nothing
While select_a_DraftingEntity("Select a Drafting Object for Reporting info", draftingEntity, cursor) = Selection.Response.Ok
'here we output the Tag of the selected Drafting Object - dimension, weld symbol, GDT; etc...
NX("Tag of selected Drafing Entity :" & draftingEntity.Tag)
Dim mySelectedDraftEntity As Annotation = Utilities.NXObjectManager.Get(draftingEntity.Tag)
NX("")
'the Object Type to string...
Dim DraftEntityType As String = (mySelectedDraftEntity.GetType.ToString).Split(".")(2)
NX("Drafting entity Type :" & DraftEntityType)
NX("")
'lets find the Type
'Dimension = type 26
'DraftingFcf = type 25
'DraftingDatum = type 25
'LineWeld = type 25
'DraftingSurfaceFinish = type 158
'IdSymbol = type 25
'CustomSymbol = type 25
Dim type As Integer
Dim subtype As Integer
ufs.Obj.AskTypeAndSubtype(mySelectedDraftEntity.Tag, type, subtype)
NX(type)
Select Case type
'--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Case = 26 'if Dimension
Dim myDimension As Annotations.Dimension = Utilities.NXObjectManager.Get(mySelectedDraftEntity.Tag)
Dim mainText() As String = Nothing
Dim dualText() As String = Nothing
Dim myUpperTolerance As Double = Nothing
Dim myLowerTolerance As Double = Nothing
myDimension.GetDimensionText(mainText, dualText)
myUpperTolerance = myDimension.UpperMetricToleranceValue
myLowerTolerance = myDimension.LowerMetricToleranceValue
NX(mainText.Length)
NX(dualText.Length)
NX("Dimension Main Text :" & mainText(0))
' NX("Dimension Dual Text :" & dualText(0))
NX("UpperTolerance :" & myUpperTolerance)
NX("LowerTolerance :" & myLowerTolerance)
'lets try extract the Object the dimension is associated to...
Dim myNumberOfAsso As Integer = myDimension.NumberOfAssociativities
Dim anAsso As Associativity
NX("have associated origin :" & myDimension.HasAssociativeOrigin)
NX("number of associatives :" & myNumberOfAsso)
'lets try UFS instead..
Dim myData() As UFDrf.ObjectAssocData = Nothing
For i As Integer = 1 To myNumberOfAsso
anAsso = myDimension.GetAssociativity(i)
NX(anAsso.ToString)
ufs.Drf.AskAssociativityData(myDimension.Tag, i, myData)
NX(myData.Length)
anAsso = myDimension.GetAssociativity(1)
Dim obj As NXObject = anAsso.FirstObject
NX(obj.Tag)
NX(obj.ToString)
' hmmm - how to extract info from the "myData" array...?
Next
'--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
End Select
NX("=====================================")
End While
End Sub
'=============================================================================================
End Module