Jump to content

Assign a different variable to each item in a list


drafter_joe

Recommended Posts

No problem, Joe!

Once I was also confused as you are - No idea what to do when I had some list, and was used to separate items only with setq function.

Thankfully the other guys who replied here helped me to get this far.

Link to comment
Share on other sites

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • drafter_joe

    11

  • Tharwat

    5

  • Grrr

    3

  • David Bethel

    2

Top Posters In This Topic

This may be usefull for a similar task makes the vertices a single list of x,y or x,y,z for 3d plines a simple length check determines 2d or 3d.

 

(123.45 678.90 234.56 789.0) 2x2d points

 

; pline co-ords example
; By Alan H
(defun getcoords (ent)
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   (setq obj (vlax-ename->vla-object ent))
   "Coordinates"
     )
   )
 )
)

(defun co-ords2xy ()
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq len (length co-ords))

(if (= (vla-get-ObjectName obj) "AcDb3dPolyline")
(progn
(setq numb (/ len 3))
(setq odd "yes")
)
(progn
(setq numb (/ len 2)) ; even and odd check required
(setq odd "no")
)
)

(setq I 0)
(repeat numb
(if (/= odd "yes")
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
)
(setq co-ordsxy (cons xy co-ordsxy))
(if (= odd "yes")
(setq I (+ I 3))
(setq I (+ I 2))
)
)
)

; program starts here
(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
(co-ords2xy) ; list of 2d or 3d points making pline
; list is co-ordsxy

Link to comment
Share on other sites

Thanks for your contribution, BIGAL! This is something I will probably come back to and have a use for it.

 

Joe

Edited by drafter_joe
Moved question to a new thread.
Link to comment
Share on other sites

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