Jump to content

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


mitre962

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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