chrisdvalentine Posted June 17, 2010 Share Posted June 17, 2010 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 Look into the functions getpoint and getcorner, then use ssget with _C or _W mode Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 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"))) ) Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 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. Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 AH I will take a look! you posted before I got a chance to hit reply on the last message...LOL Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 Why not just filter for the layer you want in the SelectionSet filter? Or do you need the other objects for something else? Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 Ok, then just use a Window Selection with a filter for the layer you wish to select. Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 That is a description of what I am trying to do. I just not sure what I am doing wrong. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 You're not using a Window selection - read the help file on ssget Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 (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 "") ) ) Quote Link to comment Share on other sites More sharing options...
CHLUCFENG Posted June 17, 2010 Share Posted June 17, 2010 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 Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 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 I'm not sure what you mean in the 'same setq' but anyway, the code is there now. Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 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 Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 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. Quote Link to comment Share on other sites More sharing options...
chrisdvalentine Posted June 17, 2010 Author Share Posted June 17, 2010 (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. (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]) ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 True, I would also add a (princ) to the end, I just left it as you had it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.