0

I want to store data in an array using an 4th degree equation. But i only want points from a certain range. My range needs to be x=0,2*Q to x=1,5*Q, so the loop needs to start at x=0,2*Q and ends when x=1,5*Q. Q is a variable read from a text file, and is for example 9. I use this data to draw curves in a 3D Cad program called Solid Edge. The problem is, the data doesn't store how i wnat it. It does start from were i want it but doesnt end at the point i want it. The program stops when y is that number. But i only want that to happen with x.

My solid edge version is ST2, and this console application needs to work on ST5. In solid Edge i use the calculated array to make curves with:

Bsplinecurve2d = BsplineCurves2d.AddByPoints(order, ArraySize, dataArray)

I'm using visual basic 2003, and i know using a newer version is better. But i can't. I'm an intern at a engineering office and they only had this copie of visual basic. Here is the part of my code what isn't doing what i want:

    dim x as double
        dim y as double
dim i as double
    Dim listofdata As New ArrayList
         For i = 0.2 To 1.5 Step 0.1
                    x = (i * Q)
                    y = (((x ^ 4) * A) + ((x ^ 3) * B) + ((x ^ 2) * C) + (x * D) + E)
                    listofdata.Add(x)
                    listofdata.Add(y)
                Next
                Dim dataArray() As Double
                dataArray = DirectCast(listofdata.ToArray(GetType(Double)), Double())
  • Where is the text file in your code? – Jodrell Nov 22 '12 at 14:21
  • This is just a part of my code, to post my whole code it will a bit much. The text file gets read by a streamreader that reads the data in substrings. –  Nov 22 '12 at 14:58
  • As things stand, I don't quite understand what you are asking. – Jodrell Nov 22 '12 at 15:03
  • It wasnt very clear indeed. I've changed it a bit now, i hope it's better now. If not i will make it better next week, because i don't got much time at the moment. –  Nov 22 '12 at 15:14
  • I don't quite follow neither. i is your counter here and will stop at 1.5. x doesn't do anything to stopping, and if Q <> 1 then x will never end at 1.5. Could you elaborate a little more? You want the loop to break when result of iQ =1.5? –  Nov 22 '12 at 15:14
  • Ah okay thank you i will, but that will be this weekend or monday. –  Nov 22 '12 at 15:16
  • Are you sure you want `x` and `y` in your list sequentially? like `x1`,`y1`,`x2`,`y2`,`..` and not in some kind of structure, or separate arrays? Just wondering. – John Alexiou Nov 22 '12 at 15:34
  • I think you need to show as what `SolidEdge` is expecting in `dataArray` before we can comment on the code. – John Alexiou Nov 22 '12 at 15:43
  • What `ST` version are you targeting? It makes a difference in which version of `vb.net` is supported. – John Alexiou Nov 22 '12 at 15:48
  • I wnat my loop to stop when x=1,5Q, and i wnat to store is like x1,y1,x2,y2 because thats tghe order i need for solid edge to read the array. And i am making this with ST2 and it also needs to work on ST5. –  Nov 26 '12 at 07:26
  • Q is read from a text file because, there ar muliple rows in the file with different data in it to make a curve. AL the lines that are in the text file should be read and from al of them needs to make a curve. –  Nov 26 '12 at 07:40

1 Answers1

0

OK i figured it out. My counter stopped before x=1.5*Q somehow. But when i made it x=1.6*Q the array stops at the right and. Not sure why i had to that, but it workd now.