Jump to content

quick select lisp command please...


MikeP

Recommended Posts

Very close...

 

(defun c:hex (/ ss)
 (if (setq ss (ssget "_:L" '((8 . "3D_HWR"))))
   ((lambda (i)
      (while (setq e (ssname ss (setq i (1+ i))))
        (command "_.explode" e)
      )
    )
     -1
   )
 )
 (princ)
)

 

 

However, with the explode command, you have to step through the entities.

Link to comment
Share on other sites

  • 1 year later...

I recommend you select similar Rivilis Alexander. It works great. some reviewers: http://www.theswamp.org/index.php?topic=28032.msg340533#msg340533

The choice of primitives on the model - the team _SelSim

The choice of primitives on the model of the already selected - command _SelSimSel

Setting the choice of the model - the command _SelSimOptions

Command selection on the model appears in the context menu.

Download from here: http://www.maestrogroup.com.ua/support/selsim.zip

For AutoCAD 2004-2006: SelSim2006.arx

For AutoCAD 2007-2009: SelSim2007.arx

For AutoCAD 2010-2012: SelSim2010x32.arx and SelSim2010x64.arx

Choosing a primitive (s) and you harvest the right mouse button (or dial _SELSIM the command line).

http://www.maestrogroup.com.ua/support/

 

also recommend that you try geomprops

selsim.png

Link to comment
Share on other sites

  • 8 years later...

I am trying to use 

(setq ss (ssget "_:L" '((0 . "POLYLINE")))

 

in the following code

(defun c:TRY() 
(load "C:/Users/Thomas Pitera/Downloads/20-6249 - CORINNA - URE/SLOPES/Test/LayerIsolateFreezeThaw.lsp")
(c:LIT); freezes all layers accept current
(command "CreateSurface")
(command "AddSurfaceContours" (setq ss (ssget "_:L" '((0 . "POLYLINE")))));meant to get all the contours as input
)

any pointers would be appreciated

Link to comment
Share on other sites

15 hours ago, tpitera said:

I am trying to use 


(setq ss (ssget "_:L" '((0 . "POLYLINE")))

 

in the following code

(defun c:TRY() 
(load "C:/Users/Thomas Pitera/Downloads/20-6249 - CORINNA - URE/SLOPES/Test/LayerIsolateFreezeThaw.lsp")
(c:LIT); freezes all layers accept current
(command "CreateSurface")
(command "AddSurfaceContours" (setq ss (ssget "_:L" '((0 . "POLYLINE")))));meant to get all the contours as input
)

any pointers would be appreciated

 

 

This should give you something to chew on.

(defun c:TRY (/ clayer lst e ss)
;;;(load "C:/Users/Thomas Pitera/Downloads/20-6249 - CORINNA - URE/SLOPES/Test/LayerIsolateFreezeThaw.lsp")
;;;(c:LIT); freezes all layers accept current

  ;; since i don't have access to your program, i'll just bake my own.
  ;; no need to freeze layers, turning them off is fine

  (setq clayer (getvar 'CLAYER)) ; get current layer

  ;; step through layers and turn off (making a list to turn the layers back on)
  (vlax-for x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
    (if (and (eq (vla-get-layeron x) :vlax-true) ; only continues if layer is on
             (not (eq (vla-get-name x) clayer)) ; only continues if layer isn't current
        )
      (progn
        (vla-put-layeron x :vlax-false) ; turn layer off
        (setq lst (cons x lst)) ; create list of layers turned off so you can turn them back on at end
      )
    )
  )

  (setq e (entlast)) ; last object created in drawing

  (princ "\nSelect polyline contours to add to surface: ") ; prompt user on what they're selecting
  (if (and
        (setq ss (ssget '((0 . "LWPOLYLINE")))) ; create a seletionset of LWPolylines. the "_:L" isn't not required as we don't need to filter out locked layers
        (progn
          (command "_.createsurface") ; create the surface
          (not (equal e (setq e (entlast)))) ; compare last created object (should be your new surface) with one you stored at beginning. if same, you did not create a surface and the command cancels, otherwise it continues
        )
      )
    (progn
      (sssetfirst nil ss) ; selects the polylines (mimicking a pickfirst selection) to remove the need to within the command
      (command "_.addsurfacecontours" e) ; execute add contours command. the 'e' is where we stored the newly created surface when we checked to make sure it had been created (saves us having to specify it again)
    )
  )

  (foreach x lst (vla-put-layeron x :vlax-true)) ; command is finished. time to turn the layers back on
  
  (princ)
)
(vl-load-com)
(princ)

 

Link to comment
Share on other sites

  • 1 year later...

Hi everyone! I was exactly looking for something similar to what MikeP asked for! Is there a way to select more than one color at the time! I would like to select only Lines with color 0, 7 and 256 and switch them on the layer EASED. I don't know a lot about Lisp and I've tried some stuff but I'm stuck! Thanks for your help!

(defun c:test (/ ss)
 (if (setq ss (ssget "_:L" '((0 . "LINE") (62 . 0)))) ;;;How do I add the color 7 and the color 256 from here??? ;;;
   (command "CHANGE" (entlast) "" "P" "LA" "EASED" "")
 )
 (princ)
)

 

Link to comment
Share on other sites

Try something like this:

(setq ss (ssget "_:L" '((0 . "LINE") (-4 . "<OR") (62 . 0) (62 . 7) (62 . 256) (-4 . "OR>"))))

 

  • Agree 1
Link to comment
Share on other sites

Hi ronjonp! Thanks for helping! It's not working, nothing is selected! Can I replace the OR by AND? I'm curious, What means the -4?

Thanks!

Link to comment
Share on other sites

I understood my mistake! It was the code on my first post! Thanks ronjonp! This is exactly what I was looking for! 

Here's the final lisp if it can be useful for someone else! Have a good day!

(defun c:test (/ ss)
 if (setq ss (ssget "_:L" '((0 . "LINE") (-4 . "<OR") (62 . 0) (62 . 7) (62 . 256) (-4 . "OR>"))))
(command "_.change" ss "" "P" "LA" "EASED" "") 
 (princ)
)

 

Link to comment
Share on other sites

1 hour ago, stlo said:

I understood my mistake! It was the code on my first post! Thanks ronjonp! This is exactly what I was looking for! 

Here's the final lisp if it can be useful for someone else! Have a good day!

(defun c:test (/ ss)
 if (setq ss (ssget "_:L" '((0 . "LINE") (-4 . "<OR") (62 . 0) (62 . 7) (62 . 256) (-4 . "OR>"))))
(command "_.change" ss "" "P" "LA" "EASED" "") 
 (princ)
)

 

Glad to help 🍻

Link to comment
Share on other sites

1 hour ago, stlo said:

Can I replace the OR by AND? I'm curious, What means the -4?

"and" is used when you want to have multiple checks on an entity.  Like a red line "and" its on layer 0. So all "and" conditions have to match for it to be added to the selection set. You should only use "and" when looking at different properties.

 

-4 is telling the ssget function look for lines that are black or white or bylayer. That's why its wrapped on both sides.

 

You can do this a little easier with strings because you only need a , between see below.

these are the same
(setq ss (ssget "_:L" '((-4 . "<OR")(0 . "LINE")(0 . "CIRCLE")(0 . "ARC")(-4 . "OR>"))))
(setq ss (ssget "_:L" '((0 . "LINE,CIRCLE,ARC"))))

 

 

1 hour ago, stlo said:

I see that some objects are selected but none of them are highlighted so I can't apply any changes to them?

 

you don't need to highlight them to make changes but if you want to only highlight them use sssetfirst

(defun c:test (/ ss)
  (if (setq ss (ssget "_:L" '((0 . "LINE") (-4 . "<OR") (62 . 0) (62 . 7) (62 . 256) (-4 . "OR>"))))
    (sssetfirst nil SS)
  )
  (princ)
)

 

Link to comment
Share on other sites

  • 1 month later...

Hi everyone! I'm trying to select and erase dimensions, every text that has a 2.4 height and text that has the word SEAM in it! It's not working since all text height are selecting in the process! Can someone tells me what I have to modify in my lisp! And also, I need to know if I'm on the right path! The First code selects the text height correctly but no dimension! The second one is selecting all dimensions and all text height! Here's a dwg with with some elements that needs to be selected and others that don't!

Thanks!

(defun c:RAR (/ ss)
(setq ss (ssget "_:L" '((-4 . "<OR") (0 . "DIMENSION") (0 . "TEXT") (-4 . "OR>")(-4 . "<OR") (40 . 2.4) (1 . "*SEAM*") (-4 . "OR>"))))
(command "_.erase" ss"") 
 (princ)
)
  
  
 (defun c:RAR (/ ss)
(setq ss (ssget "_:L" '((-4 . "<OR") (0 . "DIMENSION") (0 . "TEXT") (-4 . "<OR") (40 . 2.4) (1 . "*SEAM*") (-4 . "OR>") (-4 . "OR>"))))
(command "_.erase" ss"") 
 (princ)
)

 

QSELECT-DIM-TEXTHEIGHT.dwg

Link to comment
Share on other sites

17 minutes ago, stlo said:

Hi everyone! I'm trying to select and erase dimensions, every text that has a 2.4 height and text that has the word SEAM in it! It's not working since all text height are selecting in the process! Can someone tells me what I have to modify in my lisp! And also, I need to know if I'm on the right path! The First code selects the text height correctly but no dimension! The second one is selecting all dimensions and all text height! Here's a dwg with with some elements that needs to be selected and others that don't!

Thanks!

(defun c:RAR (/ ss)
(setq ss (ssget "_:L" '((-4 . "<OR") (0 . "DIMENSION") (0 . "TEXT") (-4 . "OR>")(-4 . "<OR") (40 . 2.4) (1 . "*SEAM*") (-4 . "OR>"))))
(command "_.erase" ss"") 
 (princ)
)
  
  
 (defun c:RAR (/ ss)
(setq ss (ssget "_:L" '((-4 . "<OR") (0 . "DIMENSION") (0 . "TEXT") (-4 . "<OR") (40 . 2.4) (1 . "*SEAM*") (-4 . "OR>") (-4 . "OR>"))))
(command "_.erase" ss"") 
 (princ)
)

 

QSELECT-DIM-TEXTHEIGHT.dwg 97.35 kB · 0 downloads

AFAIK you can't directly filter dimensions with a text height.

Link to comment
Share on other sites

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