Below is a smaller version of what i'm working with, but the function is the same.
It looks for a border first to figure out what scale and location of the stamp, then based on what border it finds, it activates separate defun below. Once the onf of the bdr1 or bdr2 defuns are activated, it looks for the stamp, if it finds a stamp, it displays a message in the command line. If it doesn't not find a stamp, it will insert the stamp based on the information stored from main function.
It works fine with deciding what border to look for, but when it gets to the subfuncitons, it skips the part where it looks for the stamp and pastes a new stamp on top of the old one.
;;;_________________________________________________________________________________________________________________________________;;;
(defun c:stampinsert ()
(command "limits" "off")
(setvar "cmdecho" 0)
(if (setq bdr (ssget "_X" '((2 . "border1,border2")))); selects border
(progn
(setq ename (cdr (assoc 2 (entget (ssname (ssget "P") 0)))))
(setq ins (cdr (assoc 10 (entget (ssname (ssget "P") 0)))))
(setq scl (cdr (assoc 41 (entget (ssname (ssget "P") 0)))))
(setq etypelist (list ename)); gets entity name
(setq elist (car etypelist)); converts entity name to list item
(setq slist (strcat elist))
(cond
((= slist "BORDER1") (bdr1))
((= slist "BORDER2") (bdr2))
); end cond
)
(progn
(princ "\n Standard border not present...")
)
);end if
(princ)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun bdr1 ()
(if (ssget "_X" '((2 . "stamp")))
(progn
(princ "\nStamp already on drawing") << this part is ignored
)
(progn
(setq scl1 (* scl 0.500))
(command "_insert" "*C:/.../.../.../.../.../.../.../stamp" ins scl1 "0")
(setq ss (ssget "_X" '((2 . "stamp"))))
(command "_.move" ss "" "Displacement" "-13.00,-0.8958,0.0")
)
);end if
(setq scl nil)
(setq ins nil)
(setq ename nil)
(princ)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun bdr2 ()
(if (ssget "_X" '((2 . "stamp")))
(progn
(princ "\nStamp already on drawing") << this part is ignored
)
(progn
(setq scl1 (* scl 0.500))
(command "_insert" "*C:/.../.../.../.../.../.../.../stamp" ins scl1 "0")
(setq ss (ssget "_X" '((2 . "stamp"))))
(command "_.move" ss "" "Displacement" "-15.25,-1.202,0.0")
)
);end if
(setq scl nil)
(setq ins nil)
(setq ename nil)
(princ)
)