AfraLISP - Learn AutoLISP for AutoCAD productivity

Tool System Primer

by Chris Yanchar

You need to be careful in your customizations of tools and tool palettes. Here are some basics…

Stock Tool Catalog (aka. Registered Tools)

In your C:\Documents and Settings\<Username>\Application Data\Autodesk\AutoCAD 2004\R16.0\enu\Support\RegisteredTools\ folder there is a file called AcTpTools.atc. This is the catalog of registered tools for the application. For AutoCAD I believe there are currently three "tool types" (Hatch Tool, Block Tool, and the internal/unofficial Command Tool). ADT expands on this with about 30 different tool types.

When a new tool type is added to the system it will be added into the stock tool catalog and registered with the system. Each application, including 3rd parties, will have their own stock tool catalog.

Here is what one of the stock tools in the AutoCAD stock catalog looks like :

              <StockTool>

                   <ItemID idValue="{AF0F641B-9CCE-4474-8582-EFE0A38410FC}"/>

                   <Properties>

                          <ItemName src="AcTpCatalogRes.dll" resource="185"/>

                   </Properties>

                   <Source idValue="59a63456-0025-4ea0-9cb2-608916d5177c"/>

                   <Object>

                          <ComClass>

                                 <CLSID idValue="{AF0F641B-9CCE-4474-8582-EFE0A38410FC}"/>

                          </ComClass>

                          <Module>

                                 <File>AcTcTools.arx</File>

                          </Module>

                   </Object>

             </StockTool>

ItemID: is a unique GUID for that tool type. Every instance of that tool type (e.g. Hatch Tool) will refer to that stock tool by its GUID.

Properties: is that basic set of data you see when you look at the Tool Editor in the UI. In the above case I believe the name of the tool type is in a resource dll for easy localization purposes, and then gets created into the tool name you see for your locale. Of course when you manually rename a tool, that name is saved instead for that instance. This dll also holds the default image for the tool.

The ComClass value is the GUID in your registry that points AutoCAD to the right dlls to actually run the code for the tool.

Below is a typical stock tool from ADT. There are some similarities.

             <!--AEC Door-->

             <StockTool>

                   <ItemID idValue="6A56F31F-3F7B-4f8e-B10D-39433621B3C0"/>

                   <Properties>

                          <ItemName>Door</ItemName>

                          <Description>Creates a Door</Description>

                   </Properties>

                   <Object>

                          <ComClass>

                                 <CLSID idValue="6A56F31F-3F7B-4f8e-B10D-39433621B3C0"/>

                          </ComClass>

                   </Object>

             </StockTool>

Tool Instance

Every tool in the system is unique. When you copy a tool through the UI it will be assigned a unique GUID, or Item ID. Be careful just blindly cutting and pasting xml to create new tools. Either do it through the UI or get a hold of a GUID generator program.

As for the Stock Tools, the <Properties/> node contains all the basic tool info that you assign from the Tool Editor. Only those elements that are actually in use are written out.

Each time you copy a tool through the UI a unique image is created in the form <tool type>_<Tool GUID>.ext. Since the image is auto-generated from the tool data it is really just a visual expression of that data. So, if you manually specify several tools to point to the same image, don't be surprised if deleting one suddenly renders the others with a blank image.

Image format: We chose to use PNGs because they have an alpha channel to support the tool images having a transparent background. They are also a lossless compression format.

In the example below you will see how this tool instance refers to the StockTool. This is the same one from above.

The <Data\> node is just that, all the data that you specify for that tool; in the example below it is all the data to describe the solid fill Pantone hatch.

            <Tool>

                   <ItemID idValue="{74CC8347-BEA2-46D7-B855-86700A2FD640}"/>

                   <Properties>

                          <ItemName>PANTONE 15-0525 TP</ItemName>

                          <Images>

                                 <Image cx="32" cy="32" src="Images\Hatch tool_8FC7645E-5F37-4200-8D7A-086354BBFB76.PNG"/>

                                 <Image cx="64" cy="64" src="Images\Hatch tool_8FC7645E-5F37-4200-8D7A-086354BBFB76 (1).PNG"/>

                          </Images>

                          <Description>Creates a solid fill hatch using PANTONE 15-0525 TP</Description>

                          <Time createdUniversalDateTime="2002-11-06T04:06:28"          modifiedUniversalDateTime="2002-11-06T04:06:28"/>

                   </Properties>

                   <Source/>

                   <StockToolRef idValue="{AF0F641B-9CCE-4474-8582-EFE0A38410FC}"/>

                   <Data>

                          <GeneralProperties>

                                 <Color>

                                      <BasicPropInfo>

                                            <PropValue unspecified="FALSE" valueType="2" value="0"/>

                                      </BasicPropInfo>

                                      <CreateInfo>

                                             <AcCmColor mRGB="3266557304">

                                                   <ColorName>PANTONE 15-0525 TP</ColorName>

                                                   <BookName>PANTONE(R) a &amp; i-paper</BookName>

                                             </AcCmColor>

                                      </CreateInfo>

                                 </Color>

                                 <Layer>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="1"/>

                                      </BasicPropInfo>

                                 </Layer>

                                 <Linetype>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="1"/>

                                      </BasicPropInfo>

                                 </Linetype>

                                 <LinetypeScale>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="3" value="0"/>

                                      </BasicPropInfo>

                                 </LinetypeScale>

                                 <PlotStyle>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="1"/>

                                      </BasicPropInfo>

                                 </PlotStyle>

                                 <LineWeight>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="2" value="0"/>

                                      </BasicPropInfo>

                                 </LineWeight>

                          </GeneralProperties>

                          <Hatch>

                                 <HatchType>Predefined</HatchType>

                                 <PatternName>SOLID</PatternName>

                                 <SourceFile>%INSTALL_DIR%\UserDataCache\Support\acad.pat</SourceFile>

                                 <Angle>0</Angle>

                                 <Scale>1</Scale>

                                 <Spacing>1</Spacing>

                                 <PenWidth>100</PenWidth>

                                 <Double>0</Double>

                                 <BlockExtent>0.5</BlockExtent>

                          </Hatch>

                   </Data>

            </Tool>

Tool Palettes

Tool palettes essentially have the same structure: a unique ItemID, a Properties node for the name/etc., and then all the tools contained on it.

 <Palette>

      <ItemID idValue="{EAAE2E08-02C4-4ABC-9B91-AF4C209CEAC9}"/>

      <Properties>

             <ItemName>General Drafting</ItemName>

            <Images/>

             <Description>This palette contains a sampling of basic 2D drafting tools</Description>

            <Time createdUniversalDateTime="2002-11-06T21:45:34" modifiedUniversalDateTime="2002-11-06T21:45:34"/>

      </Properties>

      <Source/>

      <Tools>

            <Tool>

                   <ItemID idValue="{2DDBB344-97D8-4085-84FD-1552F2F67430}"/>

                   <Properties>

                          <ItemName>PANTONE 8001 C</ItemName>

                          <Images>

                                 <Image cx="32" cy="32" src="Images\Hatch tool_FEDCC8B5-B55A-441D-8CA4-4720592B0494.PNG"/>

                                 <Image cx="64" cy="64" src="Images\Hatch tool_FEDCC8B5-B55A-441D-8CA4-4720592B0494 (1).PNG"/>

                          </Images>

                          <Description>Creates a solid fill hatch using PANTONE 8001 C</Description>

                          <Time createdUniversalDateTime="2002-11-06T04:06:28" modifiedUniversalDateTime="2002-11-06T04:06:28"/>

                   </Properties>

                   <Source/>

                   <StockToolRef idValue="{AF0F641B-9CCE-4474-8582-EFE0A38410FC}"/>

                   <Data>

                          <GeneralProperties>

                                 <Color>

                                      <BasicPropInfo>

                                            <PropValue unspecified="FALSE" valueType="2" value="0"/>

                                      </BasicPropInfo>

                                      <CreateInfo>

                                             <AcCmColor mRGB="3263463287">

                                                   <ColorName>PANTONE 8001 C</ColorName>

                                                   <BookName>PANTONE(R) metallic coated</BookName>

                                             </AcCmColor>

                                      </CreateInfo>

                                 </Color>

                                 <Layer>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="1"/>

                                      </BasicPropInfo>

                                 </Layer>

                                 <Linetype>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="1"/>

                                      </BasicPropInfo>

                                 </Linetype>

                                 <LinetypeScale>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="3" value="0"/>

                                      </BasicPropInfo>

                                 </LinetypeScale>

                                 <PlotStyle>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="1"/>

                                      </BasicPropInfo>

                                 </PlotStyle>

                                 <LineWeight>

                                      <BasicPropInfo>

                                            <PropValue unspecified="TRUE" valueType="2" value="0"/>

                                      </BasicPropInfo>

                                 </LineWeight>

                          </GeneralProperties>

                          <Hatch>

                                 <HatchType>Predefined</HatchType>

                                 <PatternName>SOLID</PatternName>

                                 <SourceFile>%INSTALL_DIR%\UserDataCache\Support\acad.pat</SourceFile>

                                 <Angle>0</Angle>

                                 <Scale>1</Scale>

                                 <Spacing>1</Spacing>

                                 <PenWidth>100</PenWidth>

                                 <Double>0</Double>

                                 <BlockExtent>0.5</BlockExtent>

                          </Hatch>

                   </Data>

            </Tool>

      </Tools>

</Palette>

 

Profiles and the Internal Workspace Catalog

Each AutoCAD Profile has associated with it an .aws file. This xml file specifies :

  • where to store the tools and palettes associated with that profile (WorkspaceCatalogPath)
  • all the tool palettes associated with the Tool Palette Set
  • the UI info specific to that user :
    • current tab
    • palette set transparency
    • size and position of the palette set
    • title bar justification and docked state
    • auto-hide state
  • the GUID of each tool palette
  • the order of each tool within the palette

All this allows you to set up Profiles where each user can be pointing to the same tool palettes, but each user stores their own UI/personal preferences.

In the Options dialog under Files, you will see that you can change the location from which to store/retrieve tool palettes from. One use-case would be a different profile for different projects, each pointing to a unique folder in which to store your project-specific tool palettes.

Adding Tools and Tool Palettes from Outside AutoCAD

In AutoCAD, via the Customize dialog you can export out a palette and import it into another profile. An .xtp file is essentially a tool palette file with the UI info saved with it that was from the workspace catalog.

You can also import a single tool or tool palette by dropping the .atc file from File Explorer.

Lastly, you can package tools and tool palettes in i-Drop packages and deliver them over the web. The i-Drop object in your main html file would be something like :

    <object name="idrop" classid="clsid:21E0CB95-1198-4945-A3D2-4BF804295F78" width="16"

   height="16" align="right">

     <param name="background" value="../images/background.jpg">

     <param name="proxyrect" value="0,0, 16,16">

     <param name="griprect" value="0, 0, 16,16">

     <param name="package" value="./Tool Palettes/Idrop-Annotation.xml">

     <param name="validate" value="1">

   </object>

The i-Drop package that is referred to above "./Tool Palettes/Idrop-Annotation.xml" would be something like the following, where the dataset and datafile refers to the actual .atc file for the individual palette. For tools the clipformat is :

"CF_IDROP.XML_ACTCUI_TOOL"

      <!-- xmlns="x-schema:idrop-schema.xml" -->

    <proxy defaultsrc="../images/iDropButton.gif" />

    <dataset defaultsrc="Tool Palettes/Annotation_0656B653-D7C2-41BE-B55B-ADFAFD56E6E3.atc ">

         <datasrc clipformat="CF_IDROP.XML_ACTCUI_PALETTE">

                  <datafile src="Tool Palettes/Annotation_0656B653-D7C2-41BE-B55B-ADFAFD56E6E3.atc"/>

          </datasrc>

    </dataset>

</package>

Adding a New Tool Type

This aspect is probably beyond the main user group here, but there is also functionality in the 3rd Party API's that will allow 3rd parties to create new tool types, which can also be delivered via the web. The process goes something like this :

  1. User drops a tool from a 3rd Party's website that is actual new functionality, in other words an "unregistered" tool. All that is downloaded is the basic tool properties: name, image, etc. and a link to an MSIEXEC file back on the vendor's website.
  2. AutoCAD will inform the user that it is a new tool and do they wish to install now or defer to later.
  3. When they choose to install the new tool, the system will download the MSI installer and install the tool. Now that tool is registered with the tool system and part of the user's stock tool catalog.

And, that's all. I hope this explains a bit more of the details and gets you all even more excited about the possibilities ahead.