hi There
This is my 1st Post in the autolisp forum area
i hope That This is somewhat useful, i use This daily
Code:
;;;**********************************************
;;;<This routine sets the Layer and the Entity Name Command current>
;;;**********************************************
;;; original code by randy l. sanders c 1995
;;; a simple idea that could be expanded upon
;;;**********************************************
;;; select an Item, Entity on The Screen
;;; This not only sets That Entities Layer current
;;; but also sets That Entities Name-Command current
;;; select a Block and then the Block's Insertion Layer is set current
;;; and you are in the Insert command with that Block being inserted into the dwg
;;; ok, select a piece of Text,
;;; you go to that Text's Layer
;;; and you are in the Text Command,
;;; There is a Pattern forming here
;;; hey add your own Ideas <shown below>
;;;**********************************************
(defun c:doit (/ ec cm bk la x41 y42 z43 )
(setq EC (entsel "Entity to match Command: "))
(setq CM (cdr (assoc 0 (entget (car EC)))))
(setq BK (cdr (assoc 2 (entget (car EC)))))
(setq LA (cdr (assoc 8 (entget (car EC)))))
(setq x41 (cdr (assoc 41 (entget (car EC)))))
(setq y42 (cdr (assoc 42 (entget (car EC)))))
(command "layer" "s" LA "")
(prompt (strcat "\nCommand Set to: Command: " CM ", Layer: " LA " :"))
(cond
((eq CM "DIMENSION") (command ".dim"))
((eq CM "VIEWPORT") (command ".mview"))
((eq CM "HATCH") (command ".bhatch" "p" bk x41 "" pause))
((eq CM "INSERT") (command ".insert" bk pause x41 y42))
((eq CM "LWPOLYLINE") (command ".pline"))
((eq CM "3DSOLID") (command ".box"))
((eq CM "AEC_WALL") (command "_AecWallAdd"))
;;;; This is where you can add your own Ideas <right here>
;;;; ((eq CM "GO-FOR-IT") (command "go-for-it"))
(T (command cm))
)
(princ)
);eof