Jump to content
mitre962

LISP routine to insert a block at co-ords which are dwgname dependant

Recommended Posts

mitre962

Please help!

 

New to writing LISP's, never used cond before.

 

I'm trying to create a LISP which inserts a block whom's insertion point is determined using a cond statement which evaulates the dwgname variable and returns a value for the insertion coordinates depending on what the dwgname is.

 

If neither are true, it asks for the insertion point to be picked.

 

Please note that stamp.dwg is in my support path so should be able to be located by AutoCAD.

 

Here is what I have...

 

(defun c:insertstamp (x y filename)

(setq filename (getvar dwgname))
(stamp:getcoord)



(defun stamp:getcoord ()

(cond 
	(
		(= filename A1L.dwg) ((setq x (778.5)) (setq y (204.6716)) (stamp:insert)
	)

	(
		(= filename A1P.dwg) ((setq x (531.5)) (setq y (204.6716)) (stamp:insert)
	)

	(t
		(setq ins (getpoint "Pick Point to Label: ")) (stamp:insert1)
	)
)
)



(defun stamp:insert ()
(command _insert stamp.dwg (x,y))
)



(defun stamp:insert1 ()
(command _insert stamp.dwg ins)
)

)

 

THANKYOU!

Share this post


Link to post
Share on other sites
mitre962

EDIT: Oops, just noticed the text "Pick point to label: " should read "Pick Insertion Point"

Share this post


Link to post
Share on other sites
David Bethel

Try using quotes on drawing name

 

"A1L.DWG"

 

Also I would suggest testing both names in upper case

 

(eq (strcase filename) (strcase "A1L.dwg"))

 

 

 

(defun stamp:insert ()
   (command "_.insert" "stamp" (list x y))
   (while (> (getvar "CMDACTIVE") 0)
             (command "")) 
)

 

-David

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...