5 Simple AutoLISP Selection Sets

Not being a programmer I am not going to get into the technical details of constructing AutoLISP code, but I am going to share with you 5 simple AutoLISP codes to help you make selection-sets. I use these all the time and I even plug them into scripts and macros (more on that later). Here they are:

Select objects on a layer:

(ssget "x" (list (cons 8 "LayerName")))

Replace LayerName with the layer on which objects you want to select.

Select blocks:

(ssget "x" (list (cons 2 "BlockName")))

Replace BlockName with the name of the blocks you want to select.

Select an object type:

(ssget "X" (list(cons 0 "EntityName")))

EntityName could be LINE, LWPOLYLINE, CIRCLE, etc… Experiment with it. For example to select all lightweight polylines, you would type (ssget “X” (list(cons 0 “LWPOLYLINE”)))

Select text with a specific text style:

(ssget "X" (list(cons 7 "TextStyle")))

Replace TextStyle with the name of a text style to select text objects on that text style.

Select objects with a specific linetype:

(ssget "X" (list(cons 6 "LinetypeName")))

Replace LinetypeName with the name of a linetype to select objects with that linetype.

Once you enter a selection set on the command line, simply invoke a command (such as move, if you want to move the objects) and when it asks for a selection, type P for previous. It’s that simple!

Just another way to work lazier smarter!

7 Comments so far

  1. Lazy Drafter » Writing Scripts on August 27th, 2008

    [...] you know that you can plug in AutoLISP code into your scripts? Let’s say you want to create a selection set of objects on a certain layer and change them to another layer. You could write a script like [...]

  2. CadKicks.com on November 14th, 2008

    5 Simple AutoLISP Selection Sets…

    You’ve been kicked (a good thing) – Trackback from CadKicks.com…

  3. Matt Savone on November 25th, 2008

    I used notepad to write
    (ssget "x" (list(cons 0 "circle")))

    I named it scircle.
    The file loaded fine but when I type scircle at
    the command line I get unknown command.

    Thanks, Matt

  4. KewlToyZ on April 28th, 2009

    Hmmm,(defun scircle()(ssget "x" (list(cons 0 "circle")))(command "chprop" x "" "Layer" "DefPoints" ""))?

  5. Paramanathan on May 20th, 2009

    Dear Sir,

    i need a pgm that

    1. prompts for Radius of circle

    2. when Radius is given, all the cirlces of similar diameter ( tolerance of /- .05 , precision two decimal places) in the dwg should be grip selected

    3. so that i can change the selected (Grip highlited) circles to different layer with layer name being their diameter.

    i had almost done, except that, each time i have to alter the radius value in the code,
    below is the code

    (defun c:SIMRAD ()

    (setq rad (cdr (assoc 40 (entget (car (entsel))))))
    (alert (strcat “Radius = ” (rtos rad 2)))
    (princ)

    (cadr(sssetfirst nil(setq ss_grip (ssget “_X”‘((0 . “CIRCLE”)(-4 . “=”)(40 . 4.0 ))))))

    )

    can somebody suggest a solution

  6. Caddman on December 9th, 2010

    Hi,

    I want to erase a dynamic block by script, is there a selection set for this?

    Thanks

  7. Josh on January 13th, 2011

    Caddman, have you tried this?

    (ssget “x” (list (cons 2 “BlockName”)))

Leave a reply