PDA

View Full Version : doit.lsp


randy.77505
2005-01-10, 08:56 PM
hi There

This is my 1st Post in the autolisp forum area
i hope That This is somewhat useful, i use This daily

;;;**********************************************

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

kennet.sjoberg
2005-01-10, 11:59 PM
Welcome randy, You and I "emits a bright aura"

that is safe to know ; )

: ) Happy Computing !

kennet

RobertB
2005-01-11, 04:43 AM
((eq CM "INSERT") (command ".insert" bk pause x41 y42))

It was nice of you to post something like that. I still use something similar that I wrote 15 years (gasp!) ago.

Might I suggest the following change to the line quoted?
((eq CM "INSERT") (command "._insert" bk "_s" x41))

That gives you the block scaled while dragging for the insertion and, really, how often do we need different X/Y scaled blocks?

randy.77505
2005-01-11, 03:46 PM
hi There

RobertB

Thanks for the comment and useul suggestion
i am sure That is an improvement to the code

16 years ?? how sweet it is

;;;

Thanks

Randy

RobertB
2005-01-11, 03:53 PM
I couldn't believe it, when I looked at the header for my file. I could have sworn it was only 10 years ago. BwaHaHa!!!