Author Topic: CHPROP on (entlast) after GUI command INSERT  (Read 1440 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
CHPROP on (entlast) after GUI command INSERT
« 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.



V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: CHPROP on (entlast) after GUI command INSERT
« Reply #1 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 "")
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: CHPROP on (entlast) after GUI command INSERT
« Reply #2 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)
)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: CHPROP on (entlast) after GUI command INSERT
« Reply #3 on: February 21, 2020, 10:19:12 AM »
Marko, V-Man thanks, both of your solutions seem to works properly.