Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Annotation in Visual Basic 1

Status
Not open for further replies.

Twullf

Mechanical
Jan 24, 2012
196
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.


 
Replies continue below

Recommended for you

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:
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)
 
Also, look up the CreateNote method of the AnnotationManager object, you may have an easier time using that one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor