CADmep Properties via AutoLISP

If you’re an AutoLISP programmer and use Autodesk Fabrication CADmep, you most likely know that there’s a COD Scripting language in Autodesk Fabrication that provides read and/or write access to CADmep properties. The problem with COD Scripts, is that sometimes they’re not powerful enough to do all of the other things you’d like to do and you may want to use AutoLISP.

What you may not know is that you can access the vast majority of CADmep properties from AutoLISP. To so this, you need to configure CADmep’s List Setup dialog which will provide a light weight but similar interface to what you see when you build reports in Autodesk Fabrication. 

To access List Setup, right-click in an open area or the drawing editor and then select “CADmep” -> “Setup” -> “List Setup” from the menu. 

List Setup will Provide access to CADmep Properties

Configuring List Setup will provide access to the configured properties via DXF codes which are one of the most common ways of accessing object properties in AutoLISP. (You can also access these same DXF based properties via VBA, ARX or .Net)

The following image shows the List Setup dialog before (left) and after (right) being configured. Simply add the properties you want to extract in the order you want them.

Before and After Configuration of List Setup

Once you’ve configured the properties you want, a simple call to the (ENTGET) function in AutoLISP will return the data you’re looking for. You can see in the following image, that we’ve saved the DXF data to two different variables in the VisualLISP editor. The listsetup-blank variable (left) was done before configuration and the listsetup-config variable (right) was done after the configuration of List Setup.

CADmep Properties can be Found in the 300 DXF Group Codes

The code used to extract the data is the following….

(setq listsetup-blank (entget (car (entsel))))
(setq listsetup-config (entget (car (entsel))))

Because the VisualLISP editor does not word wrap it’s results, you can use the Inspect

Now, there are a few things to know about this method….

  • All CADmep properties show up in DXF Group Code 300. If you are returning multiple properties, you’ll have multiple 300 codes to parse through.
  • The order the properties are configured in List Setup is the order the properties will appear when returned in AutoLISP. There really is no other foolproof way of knowing which codes are which properties (unless obvious by their value) without knowing the order List Setup was configured.
  • If you later change the properties or their order, you’ll likely break your existing code. Think carefully about what you may want later and add it from the start even if you don’t want it at this time. If you need to add properties later, simply add them to the end of the list.
  • This method works well for reading Fabrication properties. It doesn’t allow you to set them using functions like “(ENTMOD)” or “(ENTUPD)