Submitted by Tomiuck R on Fri, 03/31/2017 - 06:01
Forums:
I am looking to have an adjustable drawing template that adjusted with the size of the sheet size. I have created this successfully but when creating large sheet sizes the title block and revision block become illegible due to size.
I have created the blocks in a way that the font size determines the scale of the block size. All I need to do is have a journal file that selects the tables and changes the font size based on a user input.
If anyone could help it would be much appreciated.
re: text size in tabular note
The code below illustrates how to change the text size in a tabular note. The new text size is hard-coded in this example; you can calculate the desired text size from the sheet size or if you want user input, you can combine it with code similar to:
http://nxjournaling.com/content/user-input-input-boxes
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")
lw.Open()
Dim allTabularNoteTags As New List(Of Tag)
FindTabularNotes(allTabularNoteTags)
'lw.WriteLine("Number of tabular notes found: " & allTabularNoteTags.Count.ToString)
Dim firstTable As Annotations.Table = Nothing
firstTable = Utilities.NXObjectManager.Get(allTabularNoteTags.Item(0))
Dim firstTabNoteTag As Tag = Tag.Null
Dim firstTabNote As Annotations.TableSection = Nothing
theUfSession.Tabnot.AskNthSection(firstTable.Tag, 0, firstTabNoteTag)
firstTabNote = Utilities.NXObjectManager.Get(firstTabNoteTag)
Dim tableSectionBuilder1 As Annotations.TableSectionBuilder
tableSectionBuilder1 = theSession.Parts.Work.Annotations.TableSections.CreateTableSectionBuilder(firstTabNote)
tableSectionBuilder1.Style.LetteringStyle.GeneralTextSize = 0.25
Dim temp As NXObject = Nothing
temp = tableSectionBuilder1.Commit()
tableSectionBuilder1.Destroy()
lw.Close()
End Sub
Sub FindTabularNotes(ByRef tagList As List(Of Tag))
Dim tmpTabNote As NXOpen.Tag = NXOpen.Tag.Null
Dim NxType As Integer
Dim NxSubtype As Integer
Do
theUfSession.Obj.CycleObjsInPart(theSession.Parts.Work.Tag, UFConstants.UF_tabular_note_type, tmpTabNote)
If tmpTabNote <> NXOpen.Tag.Null Then
theUfSession.Obj.AskTypeAndSubtype(tmpTabNote, NxType, NxSubtype)
If NxSubtype = UFConstants.UF_tabular_note_subtype Then
tagList.Add(tmpTabNote)
End If
End If
Loop Until tmpTabNote = NXOpen.Tag.Null
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
I Just recently had time to
I Just recently had time to look into this. I am trying to use your code but it appears that it is not changing the text size. I am using this on NX10/11 is there a change that i need to do?
re: tabular note text size
I've tested the code on NX 11 and it works for me. Note that the example journal works on the first tabular note that it finds in the file; if you are testing with an existing file, the first tabular note may not be the one you are interested in. Drawing templates make use of tabular notes; do not test the example code on a file that makes use of one of your drawing templates or it may inadvertently change the text size of your title block. Try creating a new, blank file and creating a small tabular note to test with. Also note that the tabular note cell "fit" methods may influence the final text size. In my test file I had "wrap", "auto size row", and "auto size text" options turned on (and in that order).
Yes, I have got it working in
Yes, I have got it working in a new session. Is there a way to use this to select a set of tables. I currently have the ID numbers of the tables, for example ID 115166.
re: object ID
The code in the following thread shows how to get the ID from a given object. You could loop through the tabular notes in your part until you find the given ID. Alternately, (also mentioned in the linked thread) you might be better off giving the tabular note a unique attribute or name as the code to query these would be shorter and more concise.
http://nxjournaling.com/comment/458#comment-458
And the code in the link below shows how to find all the tabular notes in your file.
http://nxjournaling.com/comment/675#comment-675
This is great. One issue is
This is great. One issue is that all of my tables have been defined as Titleblocks. Any way to add in the Edit Definition that is required to edit these?
re: title block
When you define it as a titleblock, that pretty much locks it down for editing. Have you considered leaving your title block notes as tabular notes?
Well,I would like the title
Well,I would like the title blocks to change as the sheet changes. Leaving them as tables will not allow me to do this. At least that is my understanding.
re: title block
"change as the sheet changes"
Change in what way? You can associate the table to an object so that it moves position if the other object moves. This is accomplished with edit -> annotation -> origin... Here you can associate the tabular note with another object.
I don't know of a standard command that will change the size of the tabular note according to the sheet size. However, it could probably be done with some journal code.