TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Marc'Antonio Alessi on February 21, 2020, 09:13:41 AM

Title: CHPROP on (entlast) after GUI command INSERT
Post by: Marc'Antonio Alessi on February 21, 2020, 09:13:41 AM
; simple example:
Code: [Select]
(defun ALE_Block_Draw_Insert (NewLyr / LstEnt)
  (if (> (atof (getvar "ACADVER")) 23.0)
    (command "_CLASSICINSERT")
    (progn (initdia 1) (command "_.INSERT"))
  )
  (setq LstEnt (entlast))
  (command "_.CHPROP" LstEnt "" "_LAYER" NewLyr "")
  (princ)
)
in this sample (entlast) refers to the last entity before the command.


Title: Re: CHPROP on (entlast) after GUI command INSERT
Post by: V-Man on February 21, 2020, 09:41:32 AM
Quote
(defun ALE_Block_Draw_Insert (NewLyr / LstEnt)
  (if (> (atof (getvar "ACADVER")) 23.0)
    (command "_CLASSICINSERT")
    (progn (initdia 1) (command "_.INSERT"))
  )
  (setq LstEnt (entlast))
  (command "_.CHPROP" LstEnt "" "_LAYER" NewLyr "")
  (princ)
)

Maybe
Code: [Select]
(command ".chprop" "last" "" "_LAYER" NewLyr "")
Title: Re: CHPROP on (entlast) after GUI command INSERT
Post by: ribarm on February 21, 2020, 09:47:30 AM
Maybe :

Quote
(defun ALE_Block_Draw_Insert (NewLyr / LstEnt)
  (if (> (atof (getvar "ACADVER")) 23.0)
    (command "_CLASSICINSERT")
    (progn (initdia 1) (command "_.INSERT"))
  )
  (while (< 0 (getvar 'cmdactive)) (command "\\"))
  (setq LstEnt (entlast))
  (command "_.CHPROP" LstEnt "" "_LAYER" NewLyr "")
  (princ)
)
Title: Re: CHPROP on (entlast) after GUI command INSERT
Post by: Marc'Antonio Alessi on February 21, 2020, 10:19:12 AM
Marko, V-Man thanks, both of your solutions seem to works properly.