Hi,
Below is the sample i am trying to get all note(s) names in a current drawing sheet or drawing sheet name of a selected note but it's not working. Can some one help me in this.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations
Imports NXOpen.Drawings
Module GetWordInfo
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow = s.ListingWindow
Sub Main()
Dim dp As Part = s.Parts.Display
Dim nc As NoteCollection = dp.Notes
Dim wp As Part = s.Parts.Work
Dim dwgs As Drawings.DrawingSheetCollection
Dim sheetTag As Tag = Nothing
dwgs = dp.DrawingSheets
Dim notestring() As String
lw.Open()
'Dim laSheet As DrawingSheet = wp.DrawingSheets().CurrentDrawingSheet
'For Each notename As Note In laSheet.Notes
'lw.WriteLine(notename.Name)
'Next
For Each sheet As Drawings.DrawingSheet In dwgs
sheet.Open()
For Each a_note As Note In nc
notestring = a_note.GetText()
lw.WriteLine(sheet.Name & " , " & a_note.DrawingSheetname & " , " & notestring(0) )
Next
Next
end1:
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
re: drawing sheet of object
See the code in the link below, it will return the drawing sheet of a given annotation.
http://nxjournaling.com/comment/1095#comment-1095
Re: Drawing Sheet Of Object
Hi,
Thanks for the quick response.
I tried with the code you have given but getting "nxopen.taggedobject cannot be converted to string." this error. Below is the code i am using, please help me to solve this.
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Module Module2
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim workPart As Part = theSession.Parts.Work
Dim theUI As UI = UI.GetUI()
Sub Main()
Dim draftingNoteBuilder1 As NXOpen.Annotations.DraftingNoteBuilder
draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.Annotations.Note))
Dim nXObject1 As NXOpen.NXObject
nXObject1 = draftingNoteBuilder1.Commit()
AskDrawingSheet(nXObject1)
End Sub
Function AskDrawingSheet(ByVal theObject As TaggedObject) As Drawings.DrawingSheet
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 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)
Dim lw As ListingWindow = theSession.ListingWindow
lw.open()
lw.writeline(NXObjectManager.Get(drawingTag))
Return NXObjectManager.Get(drawingTag) ' the drawing it is on!
End Function
End Module
GopinadhGvs
re: ask drawing sheet
"AskDrawingSheet" is a function that returns a value, in this case a drawing sheet object. To make use of it, you need to assign the return value to an object of the appropriate type:
Dim theSheet As Drawings.DrawingSheet
theSheet = AskDrawingSheet(nXObject1)
"theSheet" object variable will now hold a reference to the drawing sheet that contains the object (if any). You can access the sheet's objects and methods, such as "theSheet.Name".
Re: Ask Drawing Sheet
Perfect. Tons of thanks once again for the nice explanation NXJournaling.
GopinadhGvs