Jump to content

Trying to select objects and filter selection to just one layer


chrisdvalentine

Recommended Posts

So Here is my Example:

 

I have a drawing with objects on the layer "0". There are also other layer all over. Now say out of the entire drawing I want to grab just 10 objects from the "0" layer, but there are other objects with different layers surrounding it, also there are other objects on the "0" layer. Now typically you would have to select each on individual, or you could use quick select, but it would take time for each of these. I want to be able to select with a crossing window a group of objects, and then based on user input only copy a certain set of those objects based on layer, say "0" fr instance. I want to do this without selecting anything outside the window, and only on the layer I have chosen.

 

I have a similar code, but it selects all the items on a certain layer, and I have some drawings were I only wish to copy a portion of that layer.

 

Code: ;QUICKLY SELECT OBJECTS BY LAYER NAME, SELECT MULTIPLE LAYERS AT ONCE
(DEFUN C:GL (/ NLAYER SS)
 (SETVAR "CMDECHO" 0)
 (SETQ NLAYER (GETSTRING "\n WHAT LAYERS? SEPERATE WITH COMMA:" ))        ;EXAMPLE: 0,CENTER,DIM
 (SETQ SS(SSGET "X" (LIST (CONS 8 NLAYER))))
 (COMMAND ".COPY" SS "")
 )

Anyone have ideas?

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • chrisdvalentine

    10

  • Lee Mac

    9

  • muck

    1

  • CHLUCFENG

    1

Popular Days

Top Posters In This Topic

Fun example:

 

(defun LM:GetSelectionSet ( str pt filter / gr p1 pt1 pt2 lst )
 ;; © Lee Mac  ~  17.06.10
 (princ str)  

 (while (and (= 5 (car (setq gr (grread t 13 0)))) (listp (setq p1 (cadr gr))))
   (redraw)

   (setq pt1 (list (car p1) (cadr pt) (caddr p1))
         pt2 (list (car pt) (cadr p1) (caddr p1)))

   (grvecs
     (setq lst
       (list
         (if (minusp (- (car p1) (car pt))) -30 30)
         pt pt1 pt pt2 pt1 p1 pt2 p1
       )
     )
   )
 )

 (redraw)

 (ssget (if (minusp (car lst)) "_C" "_W") pt p1 filter)
)

 

Call with:

 

(if (setq p (getpoint "\nSpecify Point: "))
 (LM:GetSelectionSet "\nSpecify Opposite Corner: " p  '((0 . "CIRCLE")))
)

Link to comment
Share on other sites

Lee,

 

Thanks for the speedy reply. I have tried variation of this a couple times in other lisp routines, I am just hung up on how to filter everything but the layer I chose. So for example I have the selection set using crossing window, while selecting I choose items on 5 layers, but I only wish to copy the "0" layer. How do I filter out the other layers.

 

I like Ideas, solving it is the fun part.

Link to comment
Share on other sites

I don't need the other objects I just don't want to have to choose around them, and I do not wish to grab anything on the chosen layer outside of the window.

Link to comment
Share on other sites

I know how to use the ssget "w" for using window. I know how to use setq's with "getpoint" and "getcorner," and I know how to set a filter by a layer set in a earlier setq. I am just not sure how to put them together to complete the lisp. I will work on it some more this evening and see what I come up with. Thanks so much for your help.

 

Chris

Link to comment
Share on other sites

(defun c:gl ( / la p1 p2 ss )
 
 (if (and (setq la (getstring t "\nSpecify Layer Filter String: "))
          (setq p1 (getpoint "\nSpecify First Point: "))
          (setq p2 (getcorner p1 "\nSpecify Opposite Corner: "))
          (setq ss (ssget "_W" p1 p2 (list (cons 8 la)))))

   (command "_.copy" ss "")
 )
)

Link to comment
Share on other sites

Chris,

 

Lee handed you the code earlier, just stack the filters in the section...

 

 
(if (setq p (getpoint "\nSpecify Point: "))
 (LM:GetSelectionSet "\nSpecify Opposite Corner: " p  '((0 . "CIRCLE")(8 . "LayerName")))
)

 

That should do the trick. By the way Lee, thanks for this tidbit, I was doing a similar function as Chris, but was listing all locked layers, then locking all layers except the one I need, selecting objects, then unlocking all layers, then relocking the previously locked layers. No wonder my LISP routines are out of breath. I appreciate the concise coding. :)

 

Chuck

Link to comment
Share on other sites

Uh oh.....I have a stupid feeling coming across my head. I did not put the underscore next to the "w". I also did not know I could put the p1 and p2 in the same setq as the layer filter.

 

Thanks,

 

Chris :oops:

Link to comment
Share on other sites

Uh oh.....I have a stupid feeling coming across my head. I did not put the underscore next to the "w". I also did not know I could put the p1 and p2 in the same setq as the layer filter.

 

Thanks,

 

Chris :oops:

 

I'm not sure what you mean in the 'same setq' but anyway, the code is there now.

Link to comment
Share on other sites

Chuck,

 

Ya I had not got a chance to go through that yet as I am at work and was working on a project. I would have went through it tonight when I got home. That is not to say I would have seen it.

 

Thanks again LeeMAc

 

Chris

Link to comment
Share on other sites

I'm not sure what you mean in the 'same setq' but anyway, the code is there now.

 

 

([color=Red]setq[/color] ss (ssget "_W" [color=Red]p1 p2[/color] [color=Red](list (cons 8 la)[/color]))))

 

Just stacking it together as shown.

Link to comment
Share on other sites

There are only two arguments for the 'setq' function, the symbol [ss] and the value returned by the ssget function which will be bound to the symbol [ss] thus creating a variable.

 

The other symbols and filter list that you highlighted are arguments for the ssget function, and have nothing to do with the setq function. The 'setq' function merely binds a value to a symbol.

 

I suggest you read the VLIDE Help file for ssget as I posted earlier and also on setq.

Link to comment
Share on other sites

(defun c:gl ( / la p1 p2 ss )
 
 (if (and (setq la (getstring t "\nSpecify Layer Filter String: "))
          (setq p1 (getpoint "\nSpecify First Point: "))
          (setq p2 (getcorner p1 "\nSpecify Opposite Corner: "))
          (setq ss (ssget "_W" p1 p2 (list (cons 8 la)))))

   (command "_.copy" ss "")
 )
)

 

It works great and was of course more then helpful.

 

I only changed the command line. :D

 

 

 

(defun c:GL2 ( / la p1 p2 ss )
 
 (if (and (setq la (getstring t "\nSpecify Layer Filter String: "))
          (setq p1 (getpoint "\nSpecify First Point: "))
          (setq p2 (getcorner p1 "\nSpecify Opposite Corner: "))
          (setq ss (ssget "_W" p1 p2 (list (cons 8 la)))))

   (command "_.copy" ss [color=Red]pause pause[/color])
 )
)

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