datum feature symbol

Hello there,
drafting page datum feature symbol letter, datum symbol in the letter window how to list or excel. How can I get the information of the letters in the datum symbol frame?

The following code will report the labels of the drafting datums found in the current work part.

Option Strict Off
Imports System
Imports NXOpen

Module Module2

Dim theSession As Session = Session.GetSession()

Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

lw.Open()

lw.WriteLine("number of GDT's: " & theSession.Parts.Work.Gdts.ToArray.Length.ToString)
For Each temp As NXObject In theSession.Parts.Work.Gdts
'lw.WriteLine(" type: " & temp.GetType.ToString)
If TypeOf (temp) Is Annotations.DraftingDatum Then
Dim myDraftingDatum As Annotations.DraftingDatum = temp
lw.WriteLine(myDraftingDatum.Label)
End If
Next

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

Hello there,
Thank you very much for your support. Can we print these letters on the drawing zones underneath the letters and add a tabular note on the dafting to the cell?

I'm not sure what you mean by "print the letters on the drawing zones underneath the letters", but you can use the information in a note object (or tabular note) and place it anywhere you like on the drawing sheet.

Hello there,
I need coordinates like DATUM A M5 in the drawing area

"A"
M5 - 1 (coordinates on paper, information on which page)

I want to print a cell on a tablet note that reads and writes a coordinate string.

I can also see in the excel and info window.

The code below will report the sheet and zone of each datum found. It sends this to the information window.

The code was written and tested with NX 9. Newer versions have the option to skip letters when labeling the zones; this version does not take skipped letters into account.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module5

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession

Sub Main()

If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

For Each temp As NXObject In theSession.Parts.Work.Gdts
'lw.WriteLine(" type: " & temp.GetType.ToString)
If TypeOf (temp) Is Annotations.DraftingDatum Then
Dim myDraftingDatum As Annotations.DraftingDatum = temp
Dim myDraftingDatumZone As New NXJSheetZoneInfo
myDraftingDatumZone = ReportAnnotationSheetZone(AskDrawingSheet(myDraftingDatum), myDraftingDatum)
lw.WriteLine("Datum: " & myDraftingDatum.Label)
lw.WriteLine("Sheet number: " & myDraftingDatumZone.Sheet)
lw.WriteLine("Zone: " & myDraftingDatumZone.VerticalZone & myDraftingDatumZone.HorizontalZone)
lw.WriteLine("")
End If
Next

lw.Close()

End Sub

Function AskDrawingSheet(ByVal theObject As TaggedObject) As Drawings.DrawingSheet
'Code written by Amy Webster of GTAC
' see nx_api4936 or nx_api4937
' This function will work for:
' an object which "Resides on drawing" or is "View Dependent In" a DraftingView
' a DraftingView
' a DrawingSheet.View
' Returns Nothing for all other (ie. model mode) objects

Dim theView As View = TryCast(theObject, View)
If Not theView Is Nothing Then
Dim sheetTag As Tag = Nothing
Try
theUfSession.Draw.AskDrawingOfView(theView.Tag, sheetTag)
Return Utilities.NXObjectManager.Get(sheetTag) ' the drawing it is on
Catch ex As NXException
Return Nothing ' it is a model view
End Try
End If

Dim viewName As String = Nothing
Dim status As Integer = Nothing
Try
theUfSession.View.AskViewDependentStatus(theObject.Tag, status, viewName)
Catch ex As NXException
Return Nothing
End Try
If status = 0 Then Return Nothing ' it is a model mode object

Dim viewTag As Tag = Nothing
theUfSession.View.AskTagOfViewName(viewName, viewTag)
Dim viewType As Integer = Nothing
Dim viewSubtype As Integer = Nothing
theUfSession.View.AskType(viewTag, viewType, viewSubtype)
If viewType = 0 Then Return Nothing ' it is view dependent in a modeling view

Dim drawingTag As Tag = Nothing
theUfSession.Draw.AskDrawingOfView(viewTag, drawingTag)
Return Utilities.NXObjectManager.Get(drawingTag) ' the drawing it is on!

End Function

Function ReportAnnotationSheetZone(ByVal theSheet As Drawings.DrawingSheet, ByVal theAnnotation As Annotations.Annotation) As NXJSheetZoneInfo

Dim info As New NXJSheetZoneInfo

Dim borderBuilder As Drawings.BordersAndZonesBuilder

If IsNothing(theSheet.BordersAndZones) Then
Return Nothing
End If

borderBuilder = theSession.Parts.Work.Drafting.BordersAndZonesObjects.CreateBordersAndZonesBuilder(theSheet.BordersAndZones)

Dim numHorizontalZones As Integer = (theSheet.Length - borderBuilder.LeftMargin - borderBuilder.RightMargin) / borderBuilder.HorizontalSize
Dim numVerticalZones As Integer = (theSheet.Height - borderBuilder.BottomMargin - borderBuilder.TopMargin) / borderBuilder.VerticalSize

'calculate zone wrt bottom left of drawing (ZoneOrigin.BottomLeft)
Dim Hcell As Double = (theAnnotation.AnnotationOrigin.X - borderBuilder.LeftMargin) / borderBuilder.HorizontalSize
Dim Vcell As Double = (theAnnotation.AnnotationOrigin.Y - borderBuilder.BottomMargin) / borderBuilder.VerticalSize

Hcell = Math.Ceiling(Hcell)
Vcell = Math.Ceiling(Vcell)

Dim theZoneOrigin As Drawings.BordersAndZonesBuilder.ZoneOrigin = borderBuilder.Origin
borderBuilder.Destroy()

Dim verticalLetterNum As Integer
Dim verticalLetter As Char

Dim horizontalNum As Integer

If theZoneOrigin = Drawings.BordersAndZonesBuilder.ZoneOrigin.BottomLeft Or theZoneOrigin = Drawings.BordersAndZonesBuilder.ZoneOrigin.TopLeft Then
'origin on left side
horizontalNum = Hcell
Else
'origin on right side
horizontalNum = numHorizontalZones - Hcell + 1
End If

If theZoneOrigin = Drawings.BordersAndZonesBuilder.ZoneOrigin.BottomLeft Or theZoneOrigin = Drawings.BordersAndZonesBuilder.ZoneOrigin.BottomRight Then
'origin on bottom
verticalLetterNum = Asc("A") + Vcell - 1
verticalLetter = Chr(verticalLetterNum)

Else
'origin on the top
verticalLetterNum = Asc("A") + numVerticalZones - Vcell
verticalLetter = Chr(verticalLetterNum)

End If

Dim theSheetNum As String = SheetNumber(theSheet)

info.Sheet = theSheetNum
info.VerticalZone = verticalLetter
info.HorizontalZone = horizontalNum

Return info

End Function

Function SheetNumber(ByVal theSheet As Drawings.DrawingSheet) As String

Dim sheetNum As Integer
Dim theSheetBuilder As Drawings.DrawingSheetBuilder = theSession.Parts.Work.DrawingSheets.DrawingSheetBuilder(theSheet)
sheetNum = theSheetBuilder.Number

theSheetBuilder.Destroy()

Return sheetNum.ToString

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

Public Class NXJSheetZoneInfo

Private _sheet As String = ""
Public Property Sheet() As String
Get
Return _sheet
End Get
Set(ByVal value As String)
_sheet = value
End Set
End Property

Private _horizontalZone As String = ""
Public Property HorizontalZone() As String
Get
Return _horizontalZone
End Get
Set(ByVal value As String)
_horizontalZone = value
End Set
End Property

Private _verticalZone As String = ""
Public Property VerticalZone() As String
Get
Return _verticalZone
End Get
Set(ByVal value As String)
_verticalZone = value
End Set
End Property

Public Sub New()

End Sub

End Class

Hello there
Thank you very much for your help. I will have one more question for you. How do I extract these data into an excel file and how do I write them into tabular cells?