Nate Holt's Blog

August 4, 2009

Support file finder – AutoCAD Electrical

Filed under: Electrical — nateholt @ 10:31 pm

Recently moved from XP to Vista. It had been a pain to learn/remember where AutoCAD Electrical support files were located. Now, the deck is re-shuffled. Who knows where the AutoCAD Electrical support files are now!?!

Here are a couple little tricks to help you find your way around.

Standard: “(findfile <filename>)” function

This is one of the base AutoLISP functions, not AutoCAD Electrical-specific. It will search all standard AutoCAD support paths for the target file you pass to it as its single argument. If it can find the file after searching the list of AutoCAD support paths in the order they’re defined, it will return the full path plus file name. If not found, it will return “nil”.

For example, I wanted to find the Spreadsheet –> PLC I/O generator source file wdio.lsp. But where is it on my new Vista installation?

This file happens to be installed in one of the AutoCAD support paths (under OPTIONS –> Files). So, I should be able to type this at the command prompt:

Command:(findfile “wdio.lsp”) [Enter]

findfile01

The “findfile” function finds my file! Its full path returned!

Note: the double backslashes is a Lisp display thing. Each double backslash display really represents a single backslash character in the file name string.

Better: AcadE-specific file search function: “(c:ace_find_file <filename> options)”

But AutoCAD Electrical has some paths to support files that are not part of the normal AutoCAD support path list. For example, I needed to open the catalog look-up database file “default_cat.mdb” with a copy of Microsoft Access. Where is that file on my Vista install?!? Typing in (findfile “default_cat.mdb”) returned nil. No good. The file is in one of the support paths specific to AutoCAD Electrical and not defined as a normal AutoCAD support path.

The solution is this function listed in the AutoCAD Electrical API help (below). It is a generic file finder function that checks for a target file in the various AutoCAD Electrical paths AND, if not found, it checks for it in the normal AutoCAD support paths (i.e. does the above “findfile” !).

findfile04

Looks like this function can be used for AutoCAD Electric path searches AND the regular “findfile” basic AutoCAD path searches.

Typing this function at the “Command:” prompt revealed the file’s location:

Command: (c:ace_find_file “default_cat.mdb” 3) [Enter]

findfile02

Using a 3 for the options argument above triggers the function to look in all of the extra support folders for PLC and for catalog lookup files.

Getting Fancier

Here’s a little program that does the above but also supports a search for electrical “.dwg” library symbols. For example, I want to open and edit my active project’s parent push button symbol for horizontal wire insert, normally-open contact. From experience, I can guess that the library symbol’s name is probably HPB11.dwg. But where is it installed on my Vista-based system??? Combining the (c:ace_find_file…) function above with this schematic libary search function (c:wd_does_block_exist…) shown in bold below, this little utility should do it all.

(defun c:acefindfile ( / str fnam )
  (setq fnam nil)
  (setq str (getstring " File name with extension: " T))
  (if (AND str (/= str ""))
    (progn
      ; First check all normal AutoCAD Electrical paths plus
      ; the normal AutoCAD support paths
      (if (not (setq fnam (c:ace_find_file str 3)))
        ; No luck yet. Check active project's library paths for
        ; match on ".dwg" file name.
        (if (not (setq fnam (c:wd_does_block_exist str) ))
          ; Still no good. Try panel layout libs.
          (setq fnam (wd_fio_does_pnlblock_exist str))
  ) ) ) )
  (if fnam
    (princ fnam) ; display nil if not found, otherwise return full file name
                 ; unless file is a block instance on active drawing. In that case
                 ; just return the block name.    
  ; ELSE
    (princ " File not found")
  )
  (princ)              
)

Let’s try it. Copy and paste the above into a little ASCII text file and call it acefindfile.lsp. APPLOAD or “(load…)” it. Then type this at the command line:

findfile03

… and there it is!

Note: if this HPB11 block had been in the active drawing, this tool would have returned that block name and would not have done a search for the file on disk.

2 Comments »

  1. […] Circuit Builder configure mode – adding a “pick from icon menu” selection Circuit Builder – embedding custom calls in the spreadsheet using (c:ace_cb_eval…) Dual Range Component Tagging: Power Vs. Control Dual range wire number tagging: Power vs. Control Wire number tagging based upon “wire type” How to execute a Lisp function, all dwgs / project-wide User enhancement to Spreadsheet-to-PLC I/O drawing tool (trim dangling wires) Multiple projects within a “Super” project (updated) User creates custom “Add New Drawing” tool Quick-fix for blank line issue in PnlPurchBOM “User Post” Support file finder […]

    Pingback by Index of AutoCAD Electrical Utilities – April 2006 through August 2009 « AutoCAD Electrical Etcetera — September 28, 2009 @ 8:21 pm

  2. […] 1 – find the wdio.lsp utility. A good way to do this is to type this at your AutoCAD Electrical ”Command:” […]

    Pingback by PLC I/O Drawing Generator – Pre-defining wire numbers – AutoCAD Electrical « AutoCAD Electrical Etcetera — November 8, 2009 @ 9:46 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.