Nate Holt's Blog

August 23, 2009

Circuit Builder – embedding custom calls in the spreadsheet – AutoCAD Electrical

Filed under: Electrical — nateholt @ 5:41 pm

A simple way to customize the behavior of the Circuit Builder tool

The Circuit Builder utility first appeared in AutoCAD Electrical 2009. It enables electrical circuits to be generated and interactively modified as they insert into your electrical schematic drawings. The key pieces of this process are a set of “template” drawings with “marker blocks” and an Excel spreadsheet that lists the selectable options.

How Circuit Builder works

Here it is in a nut-shell. The Excel spreadsheet comes into play two times. The first time, it maps a skeleton template drawing to the user’s selected circuit type. The inserted template is populated with “marker blocks” inserted at strategic points in the skeleton circuit. These carry attribute codes that maps back into the spreadsheet. As the Circuit Builder program runs, it processes each marker block that comes in with a skeleton circuit template. It looks in the spreadsheet for a match on the marker block code and presents the user with the defined options that can be inserted at that marker block’s location in the template. User picks option and the spreadsheet defines what Circuit Builder needs to do to insert that option into the circuit.

For example, part of the template for a full-voltage, non-reversing 3-phase motor circuit is shown here. One of the marker blocks carries an attribute value of “PB01”. The position of this in the control part of the 3-phase motor circuit corresponds to where a “stop” contact could be inserted. This might be a pushbutton, a relay contact, a limit switch, or something else.


 Here is what the portion of the Excel spreadsheet ace_circuit_builder.xls looks like that corresponds with this template’s marker block marked with code “PB01″…


… and then here’s how it drives the Circuit Builder’s user interface, allowing the user to interactively modify the circuit as it inserts…


OK, That’s how it works… now we have a need to customize…

Let’s say that your users need to be reminded of something when a specific option is selected. For example, let’s say that if a “stop” mushroom head pushbutton is specified for marker block “PB01” shown above, you want to remind the user to consider specifying a “jumbo” size part number. Popping up an alert dialog at this point would do the job.

How to do this? Let’s look at the ace_circuit_builder.xls spreadsheet. First task is finding this support file ( ! ). You can use the “Support file finder” idea in this posting… just type this at the AutoCAD command prompt: 

(c:ace_find_file "ace_circuit_builder.xls" 3) [Enter]

…and it searches for the file and returns the full path to it. Now open in Excel and go to the 3PH_H sheet (for three-phase, horizontal circuits). Scroll down to the section for the PB01 marker block shown below. Row 100 is what we’re interested in… the row that, if selected from the UI, inserts a mushroom head pushbutton symbol into the circuit at marker block “PB01”.


First Attempt – FAILURE!

Well, maybe we can just add a standard AutoLISP “(alert <msg>)” call as shown in red below.


Make the change to row 100, save the Excel file. Fire up Circuit Builder. Get down to the pushbutton selection and pick “Mushroom head”.

Ouch. Didn’t work. Got this goofy dialog…


Here is the problem. Circuit Builder does not recognize lisp functions embedded into the Excel spreadsheet unless they are defined as “c:” type functions. If our alert function had been defined as (c:alert “some message”), then Circuit Builder would recoginze it as it is pulled from the Excel spreadsheet. But not (alert “some message”).

Second Attempt – a Work-around

 ACE2010 has a predefined “wrapper” function we can use in our Excel spreadsheet. It provides a “c:” wrapper around the normal AutoLISP expression we want to evaluate / execute.

We go back into our Excel spreadsheet and adjust the call to that shown here. The wrapper function is “(c:ace_cb_eval …)” and provides the “c:” part so that Circuit Builder will be able to read it from the Excel entry. It is documented in the AutoCAD “Electrical Help” –> “API Help”.

Important… note that we have to replace the embedded double quotes with single quotes. So the evaluated expression becomes “(alert ‘Specify jumbo head if possible’)”. This is needed to avoid ending up with two nested sets of double-quotes.


Save the Excel file. Fire up Circuit Builder. Get down to the pushbutton selection and pick “Mushroom head”…

Second Attempt – It Worked!


There it is. An example of embedding a generic AutoLISP call into the Circuit Builder spreadsheet. This concept should open up a wide range of customization possibilities. Go for it! (If you would like help, please contact me at

Work-around for ACE2009

ACE2009 does not have this predefined (c:ace_cb_eval…) wrapper function. But we can add in a look-alike function and, as long as it get’s APPLOADED, it should work. Cut and paste below into an ASCII text file. Call it something like cb_eval.lsp. Make sure it gets APPLOADED.

(defun c:ace_cb_eval ( str / )
  (if (AND str (/= str ""))
      ; Replace any ' character found in string with double quote " character
      (setq str (wd_fr_txt_replace str "'" "\"" nil))
      (eval (read str)) ; evaluate the lisp expression
  ) )

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Blog at


Get every new post delivered to your Inbox.

Join 39 other followers

%d bloggers like this: