Jump to content

Something like an array variable ???


Recommended Posts

Posted

hello

 

is there in Visual LISP for AutoCAD something as an array variabele ?

 

like:

(defun

(setq x 1)

 

(while T

(setq pt[x] (getpoint "\nPlease pick a point"))

(setq x (+ x 1)

)

 

so if you pick a point, it's stored in pt1

you pick another point it's stored in pt2

etc... etc...

 

and if not is there an easy way to reach this?

Posted

You can use a list to hold a collection of items.

 

;;; Example
(setq mylist '())
(while T
(setq pt (getpoint "\nPlease pick a point"))
(setq mylist (cons pt mylist))
)

Posted

Using that method, you can obtain each point by using:

 

(nth [i]loc list[/i])

 

Where "loc" is the position of the item in the list (remember, the first item is 0, the second is 1, and so on) and "list" is any valid list.

 

There is a way of creating variables on-the-fly, so that you can actually access them as pt1, pt2, and so on, rather than building a list and accessing them from the list, but if you want a list of points, that method wouldn't be any good.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...