LISP Routine Request

LISP Routine Request

Jackson_Hollis_TESSERE
Contributor Contributor
480 Views
3 Replies
Message 1 of 4

LISP Routine Request

Jackson_Hollis_TESSERE
Contributor
Contributor

Sup,

 

Obligatory "I'm new to LISP's".

 

What I want the LISP routine to do:

  • I type in the command: YELLOW
  • A pre-loaded block named STAR is inserted as if you've ran the -INSERT command and selected the STAR block manually

Basically a custom command to insert a specific block. Not sure if this is possible or not.

Thanks for the help and knowledge!

 

 

0 Likes
Accepted solutions (1)
481 Views
3 Replies
Replies (3)
Message 2 of 4

james_moore
Advocate
Advocate
Accepted solution

Frankly, I think you should make a custom toolbar button for such a thing, but here goes...

 

(defun C:YELLOW ()
(command "-insert" "STAR")
)

 

This should do it.  It assumes the block "STAR" is either found on a search path, or already defined in your drawing.  It stops at the point of where do you want to insert, scale, and rotate.

 

This one asks for the insertion point up-front, then inserts the block at full scale.

(defun C:YELLOW ()

 (promt "Select an insertion point:")

 (setq USERPOINT (getpoint))
 (command "-insert" "STAR" USERPOINT "1")
)

 

Depending on your ACAD configuration, you may need to supply X and Y scale...

 (command "-insert" "STAR" USERPOINT "1" "1")

and rotation...

(command "-insert" "STAR" USERPOINT "1" "1" "0")

... so one of these lines might work for you.  There are ways to detect the environment settings and use an IF or COND statement to decide which command sequence to use.  Also note the "1" "1" "0" can probably be written 1 1 0, and using the "command" function, I know the quoted numbers will work for sure.

Message 3 of 4

Jackson_Hollis_TESSERE
Contributor
Contributor
The first routine you wrote works perfectly. TYSM!
0 Likes
Message 4 of 4

Sea-Haven
Mentor
Mentor

"Frankly, I think you should make a custom toolbar button for such a thing,"

 

I agree easy to make.

 

SeaHaven_0-1697952272602.png

 

Others here will talk about Toolpallete's.

 

 

0 Likes