cadman6735 Posted June 30, 2010 Posted June 30, 2010 I am working on a macro that will put all my entities in a drawing color to bylayer. Here is my code so far and it works but I have to select each entity one at a time. (defun C:CBL ( / oldData newData) ;=========================================== (While (setq oldData (entget(car(nentsel)))) (setq newData (subst (cons 62 256)(assoc 62 oldData)oldData)) (entmod newData) (command "REGEN") );end while ;========================================== (princ) ) Question #1 How would I use ssget to accomplish this task? (ssget "x") I am having trouble understanding how to use ssget. Question #2 (subst (cons 62 256)(assoc 62 oldData)oldData) from my above code. I don't 100% understand how this works. Why do I use oldData at the end of this function? Why do I have to call oldData twice? Can someone explain what each oldData is doing? Question #3 My ultimate goal is to be able to put all entities in a drawing plotstyle to bylayer. This seems to be a much bigger task from what I am reading. Is there not a DXF code for plot syle? How do I access the plotsyles to modify it. Seems it is a vl functions but I am not at that level of understanding LISP yet, so how was it accomplished before Visual Lisp done in "vanilla LISP"? Thanks Quote
Tharwat Posted June 30, 2010 Posted June 30, 2010 You can select all the objects in your drawing and stright to the pop-up-list of Layer Colors and select it ByLayer and that will solve the issue. Regards Tharwat Quote
JohnM Posted June 30, 2010 Posted June 30, 2010 this might be a shortcut (command "change" "all" "" "properties" "color" "bylayer" "") draw backs are: if you are in model space it will only change those objects if you are in paper space it will only chanf that tab if you want to change all objexts in model and paper you need to use ssget "x" then use a while loop with ssname Quote
Tharwat Posted June 30, 2010 Posted June 30, 2010 This will select all entities in your drawing (setq objs (ssget "_x")) Regards. Tharwat Quote
cadman6735 Posted June 30, 2010 Author Posted June 30, 2010 alanjt said: 2008 had the SetByLayer command. Thanks Alan This command does everything I want my macro to do. I wish I knew about this command before now, This is great. Thanks But I am still on the quest to understand how to do it via lisp... Can you take a crack at question #2 for me? I would like to understand how the "assoc" function works and why I have to call out oldData twice. Thanks Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 I posted this a while back about using SetByLayer: Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 Answer to question #2: Subst has three parameters that must be filled. (subst <new> <old> <list>) = the item you want to replace the old with. = the old item you want to replace with new (you don't know it, so you must call it from the list) = the list you want to edit. eg. Command: (setq lst (list (cons 1 "ALAN") (cons 2 "THOMPSON"))) ((1 . "ALAN") (2 . "THOMPSON")) Command: (assoc 1 lst) (1 . "ALAN") Command: (subst (cons 2 "NAME") (assoc 2 lst) lst) ((1 . "ALAN") (2 . "NAME")) If I want to replace item A with B, I have to call it from the list first. You're only calling the list once. The second parameter of subst is you extracting the item to replace from the list. Quote
cadman6735 Posted June 30, 2010 Author Posted June 30, 2010 alanjt said: Answer to question #2: Subst has three parameters that must be filled. (subst <new> <old> <list>) = the item you want to replace the old with. = the old item you want to replace with new (you don't know it, so you must call it from the list) = the list you want to edit. eg. Command: (setq lst (list (cons 1 "ALAN") (cons 2 "THOMPSON"))) ((1 . "ALAN") (2 . "THOMPSON")) Command: (assoc 1 lst) (1 . "ALAN") Command: (subst (cons 2 "NAME") (assoc 2 lst) lst) ((1 . "ALAN") (2 . "NAME")) If I want to replace item A with B, I have to call it from the list first. You're only calling the list once. The second parameter of subst is you extracting the item to replace from the list. Thanks again Alan It sounds so straight forward the way you put it, I could not find a good example to explain it to me in a way that I could get my head around it. Not to be greedy here but... From my understanding so far... If I want to get information about an element I have to use (entsel) & (entget) together. Where (entsel) allows me to select the element and (entget) pull the information from the element. (DxF codes) But (ssget) seems to work differently. (ssget) seems to work as a selection/filter tool. Where I have to provide (ssget) a dot list to work from. So if I used (ssget "x") this would put all my drawing elements into a selection set. But it seems I have to specify what I want to work with from the selection set, example: (0 . "Line") or (8 . 256) I can't use this selection set on multiple object such as "line" & "circles", I have to choose one or the other. Am I on the right track or is there more to ssget? Thanks again Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 Use of subst outside of editing an entity list: eg. Command: (setq lst (list "I'M" "SINGLE")) ("I'M" "SINGLE") Command: (subst "MARRIED" "SINGLE" lst) ("I'M" "MARRIED") This will also come in handy: AutoLISP Reference Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 You can use as much stuff together for ssget. eg. (ssget "_X" '((0 . "LINE,ARC,*POLYLINE") (8 . "PIZZA"))) This will select all lines, arcs and *polylines (works on same filtering principals as wcmatch) that reside on layer PIZZA. Quote
cadman6735 Posted June 30, 2010 Author Posted June 30, 2010 alanjt said: Use of subst outside of editing an entity list:eg. Command: (setq lst (list "I'M" "SINGLE")) ("I'M" "SINGLE") Command: (subst "MARRIED" "SINGLE" lst) ("I'M" "MARRIED") This will also come in handy: AutoLISP Reference Thanks for the Reference Manual this will be very handy:thumbsup: Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 cadman6735 said: Thanks for the Reference Manual this will be very handy:thumbsup: You're welcome. You can also type out a function in VLIDE, highlight and click on the help button and it will give you a full explanation of it. :wink: Quote
cadman6735 Posted June 30, 2010 Author Posted June 30, 2010 alanjt said: You can use as much stuff together for ssget.eg. (ssget "_X" '((0 . "LINE,ARC,*POLYLINE") (8 . "PIZZA"))) This will select all lines, arcs and *polylines (works on same filtering principals as wcmatch) that reside on layer PIZZA. BAM, thank you Last question, I promise (at least in this thread and for today) What is the * for before polyline? Why does the poly get the * and none of the other elements? Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 cadman6735 said: BAM, thank you Last question, I promise (at least in this thread and for today) What is the * for before polyline? Why does the poly get the * and none of the other elements? To select LWPolylines and Polylines. As I mentioned, look at wcmatch.:wink: Quote
cadman6735 Posted June 30, 2010 Author Posted June 30, 2010 alanjt said: You can use as much stuff together for ssget.eg. (ssget "_X" '((0 . "LINE,ARC,*POLYLINE") (8 . "PIZZA"))) This will select all lines, arcs and *polylines (works on same filtering principals as wcmatch) that reside on layer PIZZA. Ok, I'm sorry, one more question since I am here and thinking about it. (wcmatch, wild card match, I am reading about it now, thanks for the point) My question: (ssget "_x" '((0 . "line,arc,*polyline") The "_x" will select all elements in my drawing and the (0 . "line,arc") will filter out the lines and arcs from this selection set. So ssget is nothing more than a selection set filter? (end of story?) Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 entsel/nentsel/nentselp are single entity object selection. ssget is a multiple entity selection with very extensive filter options. Quote
cadman6735 Posted July 1, 2010 Author Posted July 1, 2010 alanjt said: entsel/nentsel/nentselp are single entity object selection.ssget is a multiple entity selection with very extensive filter options. Alan Thank you for helping me understand the ssget function, the user guide and for introducing me to wcmatch. My main confusion came from me trying to use (ssget) the same way as (entget) but for multiple objects... I am new to all this lisp stuff, so getting my head around it and swimming in too much information confusses me. Our discussion and the following web site helped me understand, maybe it will help another lost mind too. http://rkmcswain.blogspot.com/2008/08/exploring-autolisp-ssget-function-part.html http://rkmcswain.blogspot.com/2008/08/exploring-autolisp-ssget-function-part_20.html Thanks again Quote
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.