Display full version of the post: Alternative coordinate declaration VB

mikedou
16.12.2010, 19:23
Hi guys. I have written some code in VB for autocad and for the moment i am declaring the coordinates in xyz axis as following:Private Sub CreatePoints()
SidePoints(0) = 400: SidePoints(1) = -105.25: SidePoints(2) = 215
SidePoints(3) = N(8) - 400: SidePoints(4) = -105.25: SidePoints(5) = 215

SidePoints(6) = 400: SidePoints(7) = 0: SidePoints(8) = 215
SidePoints(9) = N(8) - 400: SidePoints(10) = 0: SidePoints(11) = 215.......

For example sidepoints(0),sidepoints(1),sidepoints(2) (x,y,z) are the coordinates for one point. It would be great if i could just write Sidepoints(400,105.25,215). Is there a simpler way to declare coordinates or that is the only method?

HAWDesigner
16.12.2010, 19:46
I'm not sure about the coordinates part, but all you're doing above is creating and populating an Array. So to answer your question, YES, there is an easier way to do what you're doing.You can learn more about Array's here: http://www.w3schools.com/vbscript/func_array.aspBasically what you can do is this:SidePoints = Array(400,-105.25,215, [and so on...])

mikedou
16.12.2010, 19:58

[QUOTE=HAWDesigner]I'm not sure about the coordinates part, but all you're doing above is creating and populating an Array. So to answer your question, YES, there is an easier way to do what you're doing.You can learn more about Array's here: http://www.w3schools.com/vbscript/func_array.aspBasically what you can do is this:SidePoints = Array(400,-105.25,215, [and so on...])[/QUOTE]
Unfortunately that code won't help me cause i need to make reference to specific points at some occasions. For example further down the code  i may need to declare a point equal to a previous one like: Sidepoints(1) =Rearpoints(5) .Is there a way to declare the points like i "dream"...Sidepoints(1)=(5,400,230)?Thanks you the response.

HAWDesigner
16.12.2010, 20:23
Ok, I think I understand. Yes, there is a way, but it will take some extra work to accomplish.You will be putting that information into an Array, but before you put it in the Array (and after you take it out) you will have to prepare the data. For instance:Dim SidePoints(1)Dim strX, strY, strZstrX = "5"strY = "400"strZ = "230"SidePoints (1) = strX & "," & strY & "," & strZThen, when you pull the code out of the Array, you will have to create another routine to handle that. For instance:strSidePoints=Split(SidePoints(1))
for each x in strSidePoints
    document.write(x & ",")
nextYour output should look like: 5,400,230(I'm going off of memory here, so I apologize if my code isn't 100% correct; but I hope you get the idea. ALSO, there may be an easier way to do this, that's all I can come up with at the moment.)Good Luck!!!

mikedou
16.12.2010, 20:30
Thanx again but that's not going to help either. See i have to declare 200 points more or less....

HAWDesigner
16.12.2010, 20:57
Ok, well there is a way to put this all into a loop and have it reiterate through as many points as you want.Anyways, good luck!!