I add this function to check for block if in dwg or can be located in support path for insert:
; function to locate block
; returns nil if not found
(defun findblk (nam-arg / attreq flg)
(if(not (setq flg (tblsearch "BLOCK" nam-arg))) ; look in block table
(if(setq flg (findfile (strcat nam-arg ".dwg"))) ; look in support path
(progn ; found
(setq attreq (getvar"attreq")) ; save setting
(setvar "attreq" 0) ; disable attribute dialog
(vl-cmdf"_.Insert" flg "0,0,0" "" "" "")
(entdel (entlast)) ; delete the insert
(setvar "attreq" attreq) ; restore setting
) ; progn
) ; if
) ; if
flg
)
Then include the function to check for the block here:
; Check of ETP_PID_LST3 is ingesteld en voer de blokinvoeging uit als dat zo is
(if (and ETP_PID_LST3 (not (equal ETP_PID_LST3 "0")))
(progn
; check if block is in dwg or can be inserted
(if (findblk (strcat "ETP-PID-" (nth (atoi LST3) LIJST3)))
(progn
(vla-insertblock (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-3d-point (getpoint "\Pick point to insert block: "))
(strcat "ETP-PID-" (nth (atoi LST3) LIJST3))
1 1 1 0
)
(setpropertyvalue (entlast) "Code" (strcat (nth (atoi LST1) LIJST1) "" (nth (atoi LST2) LIJST2) "" (nth (atoi LST5) LIJST5) "" (nth (atoi LST4) LIJST4)))
(princ "\nBlock inserted.")
) ; progn
(princ (strcat "\nBlock: [ETP-PID-" (nth (atoi LST3) LIJST3) "] Not Found in current drawing or in AutoCAD support path."))
) ; if
;
)
) ; if