TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jrr114 on October 06, 2020, 04:51:31 PM

Title: Layers LISP routine
Post by: jrr114 on October 06, 2020, 04:51:31 PM
I used a routine at a previous office that did what I am going to ask of the forum.  Below are samples of layers that I am using now.  The N = New, E = Existing and D = Demolition.  I want the ability to select multiple objects from N layers and switch to corresponding E layers, N and E to D.  I welcome any help that can be provided.

G-D-Case-Flor   G-E-Case-Flor    G-N-Case-Flor
G-D-Door         G-E-Door            G-N-Door
G-D-Wall-Full    G-E-Wall-Full      G-N-Wall-Full
Title: Re: Layers LISP routine
Post by: ronjonp on October 06, 2020, 05:09:40 PM
Here's a quick one.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/)
  2.   (or *foodef* (setq *foodef* "D"))
  3.   (initget 0 "D E N")
  4.   (setq *foodef* (cond ((getkword (strcat "\n[Demo/Existing/New] <" *foodef* ">: ")))
  5.                        (*foodef*)
  6.                  )
  7.   )
  8.   (ssget (list (cons 8 (strcat "G-" *foodef* "*"))))
  9.   (princ)
  10. )
Title: Re: Layers LISP routine
Post by: jrr114 on October 06, 2020, 05:26:56 PM
Thanks.  I will try this first thing tomorrow morning.  I am amazed how fast you came up with this.  It's all Greek to me.
Title: Re: Layers LISP routine
Post by: MP on October 06, 2020, 06:10:25 PM
I am amazed how fast you came up with this.

Hardly surprising -> RJP is awesome. 👍

It's all geek to me.

FTFY
Title: Re: Layers LISP routine
Post by: BIGAL on October 06, 2020, 08:28:10 PM
I dont use initget any more

Code: [Select]
(defun c:foo2 (/)
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not but)(setq but 1))
(setq *foodef* (ah:butts but "V"   '("Please choose  " "N" "E" "D")) )
    (ssget (list (cons 8 (strcat "G-" *foodef* "*"))))
  (princ)
)


Title: Re: Layers LISP routine
Post by: jrr114 on October 07, 2020, 08:54:05 AM
Big Al,
I enter FOO2 as my command.  This is the message I get.


Command: FOO2
AHbutts : dialog     {
 label ="Please choose  " ;
 : row       {
 : boxed_radio_column   {
 width = 25 ;
 : radio_button  {
key = "Rb1";
label = "N";
 }
spacer_1 ;
 : radio_button  {
key = "Rb2";
label = "E";
 }
spacer_1 ;
 : radio_button  {
key = "Rb3";
label = "D";
 }
spacer_1 ;
 }
 }
spacer_1 ;
 ok_only;
 }
; error: bad argument type: streamp nil
Title: Re: Layers LISP routine
Post by: jrr114 on October 07, 2020, 08:57:10 AM
ronjonp,

I enter FOO as my command.  I am able to select objects that are on a selected group of layers (E, D, or N).  I am unable to switch to the new status for these objects.
Title: Re: Layers LISP routine
Post by: jrr114 on October 07, 2020, 09:34:23 AM
Hey Guys,

I did some digging and found the original.  I hope this might help you in converting it to the layer system I am currently using.  Thanks again for your help.
Title: Re: Layers LISP routine
Post by: ronjonp on October 07, 2020, 10:46:40 AM
I am amazed how fast you came up with this.

Hardly surprising -> RJP is awesome. 👍
..
Thanks Michael  :-)
Title: Re: Layers LISP routine
Post by: ronjonp on October 07, 2020, 11:11:08 AM
ronjonp,

I enter FOO as my command.  I am able to select objects that are on a selected group of layers (E, D, or N).  I am unable to switch to the new status for these objects.
Give this a try. I consolidated all your options into one function.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ e nl s)
  2.   ;; RJP » 2020-10-07
  3.   (or *foodef* (setq *foodef* "DE"))
  4.   (initget 0 "DE DN ED EN NE ND")
  5.   (setq *foodef* (cond ((getkword (strcat "\nDE/DN/ED/EN/NE/ND]: <" *foodef* ">: ")))
  6.                        (*foodef*)
  7.                  )
  8.   )
  9.   (if (setq s (ssget ":L" (list (cons 8 (strcat "G-" (substr *foodef* 1 1) "*")))))
  10.     (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
  11.       (setq nl (strcat "G-" (substr *foodef* 2) (substr (cdr (assoc 8 (entget e))) 4)))
  12.       (entmod (append (entget e) (list (cons 8 nl))))
  13.     )
  14.   )
  15.   (princ)
  16. )
Title: Re: Layers LISP routine
Post by: jrr114 on October 07, 2020, 01:41:09 PM
RJP you are AWESOME!!!!!!!!!  Thank you so much!!  This is what I was looking for.  Stay well and stay safe.
Title: Re: Layers LISP routine
Post by: ronjonp on October 07, 2020, 02:44:11 PM
RJP you are AWESOME!!!!!!!!!  Thank you so much!!  This is what I was looking for.  Stay well and stay safe.
Glad to help  :-)
Title: Re: Layers LISP routine
Post by: BIGAL on October 07, 2020, 07:28:02 PM
Please re download Multi Radio Buttons.lsp from above as I had made a change to it and forgot to change back, Cadtutor is nice as only 1 copy of code is saved on the site so up to date version.

Code: [Select]
this is correct writes a temporary dcl file.
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
;(setq fo (open (setq fname "D:\\acadtemp\\test.dcl") "w"))
Title: Re: Layers LISP routine
Post by: MP on October 08, 2020, 08:57:53 AM
Thanks Michael  :-)

Just here reporting facts sir. :police:
Title: Re: Layers LISP routine
Post by: MP on October 08, 2020, 09:02:01 AM
RJP you are AWESOME!!!!!!!!!

Fun fact: The swamp has 6110 registered members. RJP was the 5th, registering the same month the swamp was born, 17 years ago.
Title: Re: Layers LISP routine
Post by: ronjonp on October 08, 2020, 11:53:14 AM
RJP you are AWESOME!!!!!!!!!

Fun fact: The swamp has 6110 registered members. RJP was the 5th, registering the same month the swamp was born, 17 years ago.
My how time flies! How did you find the stat that I was the 5th registered user?  :wideeyed2:
Title: Re: Layers LISP routine
Post by: JohnK on October 08, 2020, 12:22:22 PM
If you go to the member list and sort by the date registered but that isn't actually your ID. You were actually the 13th member to register. I cannot show you that list because it has IPs and emails and such.

In the beginning we had two forums: theSwamp and bigSwamp (big was first by quite a while). And while we were setting up the server, at Mark's house, I was behind by a few days getting my account set up at theSwamp. We planned on moving the database over from bigSwamp over to create theSwamp but I don't think we ever did.
Title: Re: Layers LISP routine
Post by: MP on October 08, 2020, 01:53:03 PM
http://youtu.be/HRcKom5_NiQ
Title: Re: Layers LISP routine
Post by: ronjonp on October 08, 2020, 03:04:10 PM
http://youtu.be/HRcKom5_NiQ
:-D