VB program worked in NX9 but not NX10
VB program worked in NX9 but not NX10
(OP)
Hi All,
I have a VB program that writes strings to an NX drawing sheet (Date, part name etc.). It works great in NX9 and earlier but in NX10 it puts the word (null) above each string that is written to the drawing sheets. Below is a bit of the code doing the writing.
example:
(null)
12-02-15
' ----------- Sheet 1 --------------------------
workPart.Layers.WorkLayer = 150
drawingSheet1 = CType(workPart.DrawingSheets.FindObject("DRAWING1"), Drawings.DrawingSheet)
drawingSheet1.Open()
Dim letteringPreferences1 As LetteringPreferences
letteringPreferences1 = theSession.Parts.Work.Annotations.Preferences.GetLetteringPreferences()
Dim userSymbolPreferences1 As UserSymbolPreferences
userSymbolPreferences1 = theSession.Parts.Work.Annotations.NewUserSymbolPreferences(UserSymbolPreferences.SizeType.ScaleAspectRatio, 1, 1)
Dim Annotations_Lettering1 As Annotations.Lettering
Annotations_Lettering1.size = .125
Annotations_Lettering1.CharacterSpaceFactor = .8
Annotations_Lettering1.AspectRatio = .8
letteringPreferences1.Angle = 0
Annotations_Lettering1.LineSpaceFactor = 1
Annotations_Lettering1.cfw.color = 181
Annotations_Lettering1.cfw.font = 1
Annotations_Lettering1.cfw.width = Annotations.LineWidth.Thin
letteringPreferences1.SetGeneralText(Annotations_Lettering1)
theSession.Parts.Work.Annotations.Preferences.SetLetteringPreferences(letteringPreferences1)
Dim stringArray1(1) As String
stringArray1(1) = mydate
Dim point3d1 As Point3d = New Point3d(4.3, 6.59, 0)
Dim note1 As Note
note1 = theSession.Parts.Work.Annotations.CreateNote(stringArray1, point3d1, AxisOrientation.Horizontal, letteringPreferences1, userSymbolPreferences1)
Dim stringArray2(1) As String
stringArray2(1) = UCase(Aline1)
Dim point3d2 As Point3d = New Point3d(1.7, 7.8, 0)
Dim note2 As Note
note2 = theSession.Parts.Work.Annotations.CreateNote(stringArray2, point3d2, AxisOrientation.Horizontal, letteringPreferences1, userSymbolPreferences1)
Dim stringArray3(1) As String
stringArray3(1) = Tapeno
Dim point3d3 As Point3d = New Point3d(4.33, 5.65, 0)
Dim note3 As Note
note3 = theSession.Parts.Work.Annotations.CreateNote(stringArray3, point3d3, AxisOrientation.Horizontal, letteringPreferences1, userSymbolPreferences1)
Any help would be greatly appreciated.
Regards,
Rick D
I have a VB program that writes strings to an NX drawing sheet (Date, part name etc.). It works great in NX9 and earlier but in NX10 it puts the word (null) above each string that is written to the drawing sheets. Below is a bit of the code doing the writing.
example:
(null)
12-02-15
' ----------- Sheet 1 --------------------------
workPart.Layers.WorkLayer = 150
drawingSheet1 = CType(workPart.DrawingSheets.FindObject("DRAWING1"), Drawings.DrawingSheet)
drawingSheet1.Open()
Dim letteringPreferences1 As LetteringPreferences
letteringPreferences1 = theSession.Parts.Work.Annotations.Preferences.GetLetteringPreferences()
Dim userSymbolPreferences1 As UserSymbolPreferences
userSymbolPreferences1 = theSession.Parts.Work.Annotations.NewUserSymbolPreferences(UserSymbolPreferences.SizeType.ScaleAspectRatio, 1, 1)
Dim Annotations_Lettering1 As Annotations.Lettering
Annotations_Lettering1.size = .125
Annotations_Lettering1.CharacterSpaceFactor = .8
Annotations_Lettering1.AspectRatio = .8
letteringPreferences1.Angle = 0
Annotations_Lettering1.LineSpaceFactor = 1
Annotations_Lettering1.cfw.color = 181
Annotations_Lettering1.cfw.font = 1
Annotations_Lettering1.cfw.width = Annotations.LineWidth.Thin
letteringPreferences1.SetGeneralText(Annotations_Lettering1)
theSession.Parts.Work.Annotations.Preferences.SetLetteringPreferences(letteringPreferences1)
Dim stringArray1(1) As String
stringArray1(1) = mydate
Dim point3d1 As Point3d = New Point3d(4.3, 6.59, 0)
Dim note1 As Note
note1 = theSession.Parts.Work.Annotations.CreateNote(stringArray1, point3d1, AxisOrientation.Horizontal, letteringPreferences1, userSymbolPreferences1)
Dim stringArray2(1) As String
stringArray2(1) = UCase(Aline1)
Dim point3d2 As Point3d = New Point3d(1.7, 7.8, 0)
Dim note2 As Note
note2 = theSession.Parts.Work.Annotations.CreateNote(stringArray2, point3d2, AxisOrientation.Horizontal, letteringPreferences1, userSymbolPreferences1)
Dim stringArray3(1) As String
stringArray3(1) = Tapeno
Dim point3d3 As Point3d = New Point3d(4.33, 5.65, 0)
Dim note3 As Note
note3 = theSession.Parts.Work.Annotations.CreateNote(stringArray3, point3d3, AxisOrientation.Horizontal, letteringPreferences1, userSymbolPreferences1)
Any help would be greatly appreciated.
Regards,
Rick D
Win7 64 bit w/NX9.0.3.4 MP9 and NX10.0.2
Vericut 7.4





RE: VB program worked in NX9 but not NX10
CODE
What you have done here is declare an array that holds two elements: stringArray1(0) and stringArray1(1). After they have been declared, they are "null" or "empty" strings. Later in your code, you assign a value to stringArray1(1), but not to stringArray1(0), leaving it as a null string.
If the notes will be single line notes, I would suggest declaring an array that only holds one element.
CODE
www.nxjournaling.com
RE: VB program worked in NX9 but not NX10
Thank you very much Cowski I would still be hunting for that one. Wonder why it worked OK in the previous versions?
Thanks again
Rick D
Win7 64 bit w/NX9.0.3.4 MP9 and NX10.0.2
Vericut 7.4
RE: VB program worked in NX9 but not NX10
Dim stringArray1 As String() = { mydate }
This way, we let the compiler figure out how long the array should be.