×
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

Create Annotation in Visual Basic

Create Annotation in Visual Basic

Create Annotation in Visual Basic

(OP)
Multiple problems with this code, hoping someone can help with two of them.

First reading a file where I want to get two strings and three double.  

CODE

 line = sr.ReadLine()
                    While Not line is Nothing
                        Dim pt1 As Point3d
                        Dim pt2 As Point3d
                        Dim noteLoc(2) as Double
                        Dim douX1Loc as Double
                        Dim douX2Loc as Double
                        Dim strLayer as String
                        Dim strMaterial as String
                        Dim douRotation as Double
                        Dim strRotate as String
                        Dim delim As Char () = { ","C }
                        Dim strings As String () = line.Split(delim)
                        strLayer = String.Parse(strings(0))
                        strMaterial = String.Parse(strings(1))
                        douRotation = Double.Parse(strings(2))
                        douX1Loc = Double.Parse(strings(3))
                        douX2Loc = Double.Parse(strings(4))
I receive the error: "'Parse' is not a member of 'String'"

I cannot seem to find the call out for reading a string from a file.

Second problem, I need to then place the strings on the drawing sheet as a note.

CODE

                       ufs.Drf.CreateNote(1,strLayer, noteLoc, 0, theNote)
                        noteLoc(0) = x + 30
                        ufs.Drf.CreateNote(1,strMaterial, noteLoc, 0, theNote)
                        noteLoc(0) = x + 65
                        strRotate = douRotation + "<$s>"
                        ufs.Drf.CreateNote(1,strRotate, noteLoc, 0, theNote)

The error I receive for this is: "Value of type 'String' cannot be converted to '1-dimensional array of String'

Documentation of the creatNote callout read:
public void CreateNote(
    int num_lines_text,
    string[] text_string,
    double[] origin_3d,
    int orientation,
    out Tag note_tag
)
Where orientation 0 means horizontal and 1 means vertical.

Any help would be greatly appreciated.


 

RE: Create Annotation in Visual Basic

To read a file line by line, you'll need to use a streamreader object (I assume that is what the sr stands for in your code). You can see some example code here: http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx

The split function returns an array of strings, there is no parse function involved, just reference them according to their offsets.

CODE

Dim pt1 As Point3d
Dim pt2 As Point3d
Dim noteLoc(2) as Double
Dim douX1Loc as Double
Dim douX2Loc as Double
Dim strLayer(0) as String
Dim strMaterial(0) as String
Dim douRotation as Double
Dim strRotate(0) as String
Dim delim As Char () = { ","C }
Dim strings As String () = line.Split(delim)
strLayer(0) = strings(0)
strMaterial(0) = strings(1)
douRotation = CDbl(strings(2)
douX1Loc = CDbl(strings(3)
douX2Loc = CDbl(strings(4)

For the last question, the CreateNote function expects, nay - demands, an array of string objects even if you are only passing in a single string. Try declaring it and assigning it as above and change your function call to:

CODE

ufs.Drf.CreateNote(1,strLayer, noteLoc, 0, theNote)

RE: Create Annotation in Visual Basic

Also, look up the CreateNote method of the AnnotationManager object, you may have an easier time using that one.

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