Jump to content

Recommended Posts

Posted

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?

 

Posted

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-" "")

 

  • Like 1
Posted (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 by ronjonp
  • Like 2
Posted
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

 

Posted
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

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

  • Like 1
Posted
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...

  • Thanks 1
Posted
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.

 

  • Like 1

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