Print Page | Close Window

Alternative coordinate declaration VB

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=4975
Printed Date: 20.May.2026 at 11:49


Topic: Alternative coordinate declaration VB
Posted By: mikedou
Subject: Alternative coordinate declaration VB
Date Posted: 16.Dec.2010 at 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?



Replies:
Posted By: HAWDesigner
Date Posted: 16.Dec.2010 at 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.asp

Basically what you can do is this:

SidePoints = Array(400,-105.25,215, [and so on...])


-------------
--
R. Williams
AutoCAD 2010 Certified Professional
<!-- If all else fails hit F1 -->
<<AutoCAD 2009


Posted By: mikedou
Date Posted: 16.Dec.2010 at 19:58
Originally posted by HAWDesigner HAWDesigner wrote:

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.asp

Basically what you can do is this:

SidePoints = Array(400,-105.25,215, [and so on...])

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.



Posted By: HAWDesigner
Date Posted: 16.Dec.2010 at 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, strZ

strX = "5"
strY = "400"
strZ = "230"

SidePoints (1) = strX & "," & strY & "," & strZ

Then, 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 & ",")
next

Your 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!!!


-------------
--
R. Williams
AutoCAD 2010 Certified Professional
<!-- If all else fails hit F1 -->
<<AutoCAD 2009


Posted By: mikedou
Date Posted: 16.Dec.2010 at 20:30
Thanx again but that's not going to help either. See i have to declare 200 points more or less....


Posted By: HAWDesigner
Date Posted: 16.Dec.2010 at 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!!


-------------
--
R. Williams
AutoCAD 2010 Certified Professional
<!-- If all else fails hit F1 -->
<<AutoCAD 2009



Print Page | Close Window