Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to use a journal to find note location on current drafting sheet

Status
Not open for further replies.

aluminum2

Aerospace
Apr 27, 2010
218


I am trying to get a location of a note with the word DWN in it on the current sheet. I was able to get the program to find it and do something, but I can't seem to get the location. I saw a command called get origin and not sure if I am using it correctly. the open api reference said the following


public void GetOrigin(
out Annotation..::..AssociativeOriginData originData,
out Point3d origin
)




Code:
'Option Strict Off  

Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Annotations
Imports NXOpen.Drawings

Module report_note_location_in_current_drawing_sheets

  Dim s As Session = Session.GetSession()
  Dim lw As ListingWindow = s.ListingWindow
  Dim dp As Part = s.Parts.Display
  Dim dc As DrawingSheetCollection = dp.DrawingSheets

Dim ufs As UFSession = UFSession.GetUFSession()



Sub Main()

    lw.Open()


            Dim sheetArray As DrawingSheet() = dc.ToArray()
            Dim currentSheet As DrawingSheet = dc.CurrentDrawingSheet


        lw.WriteLine("Sheet Name: " & currentSheet.Name)
        Dim objs As DisplayableObject() = currentSheet.View.AskVisibleObjects()

        For Each obj As DisplayableObject in objs
            'lw.WriteLine("  DisplayableObject: " & obj.ToString())

            If (TypeOf obj Is Note) Then
                Dim theNote As Note = CType(obj, Note)
                For Each text_line As String In theNote.GetText()

                     if text_line = "DWN" then
                     dim point as point3d
                     point = text_line.GetOrigin()


                    lw.WriteLine("  -> Note: " & text_line)
                    lw.WriteLine(point)





                    end if
                Next
            End If
        Next

    lw.WriteLine(" ")


End Sub

  Public Function GetUnloadOption(ByVal dummy As String) As Integer

      Return Session.LibraryUnloadOption.Immediately

  End Function

End Module
 
Replies continue below

Recommended for you

I think what you really want is the AnnotationOrigin property of the note object. You will need to get this information from the note object theNote, rather than the string variable text_line.

Code:
if text_line.ToUpper.Contains("DWN") then
dim point as point3d
point = theNote.AnnotationOrigin
.
.
.
lw.WriteLine(point.ToString)

Also, I modified the code slightly to see if the line of text contains the string "DWN" rather than checking that the line of the note exactly equals the string "DWN". This may or may not be desirable based on your needs.

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor