Jump to content

Copy Items From A List


Allan B.

Recommended Posts

Thank you for taking interest, The applications I have written are to long sent out. I will take today and check for spelling errors . I know that if I call up each items in the list separately without the foreach function, I have no problem. I am now also trying a different approach  (foreach pt list (command pt "copy"    etc,etc )) I will get back tomorrow.  Allan 

Link to comment
Share on other sites

You could always try a while loop and a counter - I tend to go that way by default but that's just me. Added some 'princ' to tell you how it is going on as an example below.. overkill but sometimes seeing it all written out helps

 

(princ "\nMy List: ")
(princ list) ;;Gives you the full list so you can see it
(setq acount 0)
(while (< acount (length list))
  (setq pt (nth acount list))
(princ "\n - count: ")
(princ acount) ; Position in list
(princ " : pt: " ;
(princ pt) ; point
  (command "copy" pt "" basept despt)
(princ "COPY OK") ; Copied OK
  (setq acount (+ acount 1))
) ; end while
(princ "All Copied")

 

If it struggles at that post what the princ statements say... should be a clue in them

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

You could also put in a check that your pt is of course selecting an object to copy... copy will fail if there is nothing selected to copy of course, something like this?

;;(if (setq mypoint (nentselp "Point" (list 0 0 0)))
(if (setq mypoint (nentselp "Point" pt))
  (progn
    (princ "Yes - An Object!") ;;do your copy command here
  )
  (progn
    (princ "No - Not an object") ;;do something else here
  )
)

 

 

 

Another question, where are you getting the list of points from?

Edited by Steven P
Link to comment
Share on other sites

No luck yet.

 I setup 2 new circle entities and put them in a list, and verified them ,  no confusion with any other objects or lists. Than I defined your code as a defun() . next I ran the function, the result 

                   entity name _______     entity name _______

           -count : 0 pt : < entity name --------->copy ok

           -count : 1 pt : < entity name---------> copy oK

    But nothing got copied  

          Allan

 

Link to comment
Share on other sites

As it happens I found something else, the structure of my main list has errors in its assembly, and that has been causing the copy command and foreach to fail after the 1st copy was made. I have to take a break from this for a few days, I will  let you know how things turn out next week. And your code was very helpful   THANK YOU      Allan

  • Like 1
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...