Jump to content

Put Coordinates into Separate List


gS7

Recommended Posts

Hey Guys ...

 

Here i need Little Help

[color="red"]([/color][color="blue"]setq[/color] ename[color="red"]([/color][color="blue"]vlax-ename->vla-object[/color] ss[color="red"]))[/color]
[color="red"]([/color][color="blue"]setq[/color] points[color="red"]([/color][color="blue"]vlax-safearray->list[/color] [color="red"]([/color][color="blue"]vlax-variant-value[/color][color="red"]([/color][color="blue"]vla-get-coordinates[/color] ename[color="red"]))))[/color]

See here the lisp returned Coordinates Like this

(7.52707 15.8253 24.8824 22.4948 30.4653 7.9432 21.2414 -1.81847 
13.9595 -1.09089)

and My Goal is I want to separate them all and put into a list

Like This

(7.52707 15.8253) (24.8824 22.4948) (30.4653 7.9432) (21.2414 -1.81847) 
(13.9595 -1.09089)

 

Help me Guys

 

Regards

Ganesh

Link to comment
Share on other sites

@Lee Mac

In this Few Minutes I Written'd a Solution Please Let Me Know The Way I Used Its Right Or Not

(setq c 0)
 (setq mtlist'())
 (repeat (1- (length points))
   (setq a(nth c points))
   (setq b(nth (1+ c) points))
   (setq pt(list a b))
   (setq mtlist (cons pt mtlist))
   (setq c (1+ c))
 )

Link to comment
Share on other sites

(setq c 0)
(setq mtlist'())
(repeat (1- (length points))
 (setq a(nth c points))
 (setq b(nth [color=red](setq c (1+ c))[/color] points))
 (setq pt(list a b))  
 (setq mtlist (cons pt mtlist))
 (setq c (1+ c))
)

 

Or another way :

 

(repeat (/ (length points) 2)
 (setq pt (list (car points) (cadr points)))
 (setq points (cddr points))
 (setq mtlist (cons pt mtlist))
)
(reverse mtlist)

 

M.R.

Link to comment
Share on other sites

If you wish to use repeat, I would suggest something along the lines of:

(defun _groupby2 ( lst / out )
   (repeat (/ (length lst) 2)
       (setq out (cons (list (car lst) (cadr lst)) out)
             lst (cddr lst)
       )
   )
   (reverse out)
)

Or recursively,

(defun _groupby2 ( lst )
   (if lst (cons (list (car lst) (cadr lst)) (_groupby2 (cddr lst))))
)

_$ (_groupby2 '(1 2 3 4 5 6))
((1 2) (3 4) (5 6))

This is also the method I demonstrate here.

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