Patrik Posted July 3 Posted July 3 Hi, Im curently working on a script to automate a bit (hopefully a lot) of work. We got a huge legacy library that has grown over the last decade or two and in an effort to make it a bit more usable im doing some cleaning in the summer. The purpose here is to first create a new layer, then i want to select all polylines that got 0 global width and move to that layer. and if possible also move to the back of the draw order. _.-layer _make vm_symb_kont _color white (ssget "_X" (list (cons 0 "*POLYLINE") (cons -4 ">") (cons 40 0.0))) _laycur Im trying with this code but ssget ends with a <Selection set: 3> line and then nothing. Command: (ssget "_X" (list (cons 0 "*POLYLINE") ((_> (cons -4 ">") ((_> (cons 40 0.0))) <Selection set: 3> Anyone got any suggestions? Quote
Steven P Posted July 3 Posted July 3 You are right the selection set will select all polylines with a width of 0. I'd select this first as a variable: (setq MySS (ssget "_X" (list (cons 0 "*POLYLINE")(cons -4 ">")(cons 40 0.0))) ) Then you need to do something with it. The report you are getting "<Selection Set: 3>" where 3 is the selection set name (specific to that running of the LISP). LISP doesn't know what to do next. You might want something like this to change the selection set to that layer: (command "chprop" MySS "" "LAYER" "-YOUR LAYER NAME-" "") 1 Quote
ronjonp Posted July 3 Posted July 3 (edited) Code 43 is for global width .. you can also entmod the items without the need to create the layer: (defun c:foo (/ s) (if (setq s (ssget "_X" '((0 . "*POLYLINE") (43 . 0.)))) (foreach e (mapcar 'cadr (ssnamex s)) (entmod (append (entget e) '((8 . "vm_symb_kont"))))) ) (princ) ) You could also use this filter but it only guarantees that the first occurrence is = 0, others could be different. (setq s (ssget "_X" '((0 . "*POLYLINE") (40 . 0.)))) Edited July 3 by ronjonp 2 Quote
Patrik Posted July 4 Author Posted July 4 13 hours ago, Steven P said: You are right the selection set will select all polylines with a width of 0. I'd select this first as a variable: (setq MySS (ssget "_X" (list (cons 0 "*POLYLINE")(cons -4 ">")(cons 40 0.0))) ) Then you need to do something with it. The report you are getting "<Selection Set: 3>" where 3 is the selection set name (specific to that running of the LISP). LISP doesn't know what to do next. You might want something like this to change the selection set to that layer: (command "chprop" MySS "" "LAYER" "-YOUR LAYER NAME-" "") Thank you, this one works fine. But when it comes to a file without polylines it breaks it gets a nil result and breaks down. When i looked in to it i noticed that some of the files got lines or circles instead of polylines. I'm thinking that i need to ad in circle and lines in the code. i have found that i proberbly need to use and/or (setq MySS (ssget "_X" (list ((-4 . "<OR) (-4 . "<AND")(cons 0 "*POLYLINE")(cons -4 "=")(cons 40 0.0)"AND>) (0 . "LINE") (0 . "CIRCLE") (-4 . "OR>") ) ) ) (command "chprop" MySS "" "LAYER" "vm_symb_kont" "") Trying something like this but it never exits the command until i manually hit escape twice (((("_> (((("_> (((("_> *Cancel* ; error: Function cancelled //Patrik Quote
Patrik Posted July 4 Author Posted July 4 15 hours ago, ronjonp said: Code 43 is for global width .. you can also entmod the items without the need to create the layer: (defun c:foo (/ s) (if (setq s (ssget "_X" '((0 . "*POLYLINE") (43 . 0.)))) (foreach e (mapcar 'cadr (ssnamex s)) (entmod (append (entget e) '((8 . "vm_symb_kont"))))) ) (princ) ) You could also use this filter but it only guarantees that the first occurrence is = 0, others could be different. (setq s (ssget "_X" '((0 . "*POLYLINE") (40 . 0.)))) Thank you for this, it runs very fast and creates the layer, but it doesn't seem to move any items to it. And its too many functions i haven't used before to understand what might be wrong. //Patrik Quote
ronjonp Posted July 7 Posted July 7 On 7/4/2024 at 4:46 AM, Patrik said: Thank you for this, it runs very fast and creates the layer, but it doesn't seem to move any items to it. And its too many functions i haven't used before to understand what might be wrong. //Patrik From my minimal testing it moves the objects to a "vm_symb_kont" layer. 1 Quote
marko_ribar Posted July 8 Posted July 8 16 hours ago, ronjonp said: From my minimal testing it moves the objects to a "vm_symb_kont" layer. @ronjonp If I understood correctly, when using BricsCAD you must go through (entupd (cdr (assoc -1 (entmod (subst (cons 8 "Layername") (assoc 8 entdata) entdata))))), and in AutoCAD you can do it through (append) like you showed... Anyway the best is that you make sure it works for both AutoCAD and BricsCAD, and that is by using (subst) method... 1 Quote
Patrik Posted July 10 Author Posted July 10 On 7/7/2024 at 10:56 PM, ronjonp said: From my minimal testing it moves the objects to a "vm_symb_kont" layer. I got it working It works great. Thank you. 1 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.