Jump to content

Creating a selection set from a list of objects inside a foreach funsction


Recommended Posts

Posted

The list of objects that I copy from a existing list needs to put into a selection set that I can manipulate them in an optimization program. I have tied to do this inside a foreach function but I keep failing at the syntax.   Example   (foreach pt (last optlist)(command "copy" pt "" baspt  despt)

                                                                      ; now create the selection set and number it for later placement

                                                           )

  The optlist can contain anywhere from 2 to 5 objects, in the selection set I need to optimize their placement with another placement, rotate, move.This is all done automatically in another lisp routine.

   I will try later to copy a cad drawing to this site for a better understanding . 

  Allan

Posted

I have just added a stsample .dwg to my post. Here you can see how I optimize my tread placement. The new selection set I hope will allow me to place drill patterns on the optimized

plates.  

Allan

stsample.dwg

Posted

In this case we need to know how optlist is generated and/or what its made up of. I myself prefer to use the foreach function.

 

If its a selection set.

(foreach ent (mapcar 'cadr (ssnamex SS)) ;used with ssget "_X"
  ;code here
  ....
)

(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) ;all other ssget's
  ;code here
  ....
)

 

with lists its even simpler.

(foreach pt optlist
  (command "copy" pt "" baspt  despt)
  ...
)

For this to work optlist would have to be entity names in that list

(<Entity name: 3820ff80> <Entity name: 3820e640> <Entity name: 3820e180> <Entity name: 3820dd80> <Entity name: 3820dec0>)

 

 

 

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