×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VB program worked in NX9 but not NX10

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

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

In .net, the arrays are zero based; that means the first element of the array is at index 0. It appears that you want to add single line notes to the drawing. Your code declares arrays like this:

CODE

Dim stringArray1(1) As String 

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

Dim stringArray1(0) As String 

www.nxjournaling.com

RE: VB program worked in NX9 but not NX10

(OP)
That worked!!!
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

The array length stuff is goofy and confusing in VB. So, I would suggest

Dim stringArray1 As String() = { mydate }

This way, we let the compiler figure out how long the array should be.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources