
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
(defun c:FH ( / *error* fp block blk)
(defun *error* (msg)
(cond
((not msg))
((wcmatch (strcase msg) "*CANCEL*"))
(1 (prompt (strcat "\nERROR: " msg)))
)
(princ)
)
(and
(setq blk (getstring "Enter Block Name:"))
(or
(setq file (findfile "FOPATH.INF"))
(alert "File 'fopath.inf' not found.")
)
(setq fp (open file "r"))
(while (not block)
(setq block (findfile (strcat (read-line fp) "/" blk ".dwg")))
)
(not (close fp))
(setq block (vl-cmdf "insert" block "scale" 1))
;; because command returns nil
)
(*error* nil)
)
I have this lisp that we use to "Hunt" in frequently used blocks. I created this and a directory to place the dwg files for each block. Each block is WBLOCK'd out to its own file and the code uses FOPATH.inf to search for the directory where the files are kept. On the first two blocks I put in work just fine. We are adding to this and each new block that is made (same way as the original two) returns ERROR: bad argument type: stringp nil and doesn't insert the block. You call which block based on typing the name of the dwg file of the block you want. Is there something that I'm missing in the code? This still works for the old ones, but does not work on any new blocks added to the list.
The FOPATH.INF file is a notebook file that contains only the directory where the blocks are located.
The screenshot below shows 2705dyn as the block that doesn't work and 32a6 as one that does. They are both in the same folder and made the same way.
Solved! Go to Solution.