Sunday, January 25, 2009

Assigning Multiple Double Click Actions to Single Entity Type in AutoCAD

In the Unleash the Double Click Power post, you saw how to customize the double click action of an entity type to implement custom double click actions. Now we are going to see how we can implement different double click actions simultaneously on single entity type. Normally, we accomplish this by using Reactors or Events in the respective languages. But, we are not going to use any of these in our method. Rather, we will follow a tricky way to achieve the same result.

As an example, I will show you how to change the double click action of an 'Attribute Block'. Normally double clicking an attribute block shows the Enhanced Attribute Editor Dialog. We are going to change this to show either Enhanced Attribute Editor(_eattedit) or Edit Attributes dialog (_attedit) depending on certain condition. Let's say, when we double click on a title block named TITLE_BLOCK, it should display the Enhanced Attribute Editor dialog and for all other blocks in the drawing, it should display Edit Attributes dialog. The step by step configuration is given below.



  1. Open CUI and create a custom command with the following code inside the macro section of the command. If you don't know how to create a custom command, then refer to the 'Unleash the Double Click Power' post mentioned above. Replace the 'TITLE_BLOCK' inside the following code with your actual title block name.
    ^C^C(if (= (cdr (assoc 2 (entget (ssname (ssget "P") 0)))) "TITLE_BLOCK") (command "_eattedit")(command "_ddatte" ))

  2. Drag and drop the custom command under the 'Attribute Block' section inside the Double Click Actions.

  3. Click on 'Apply' and close the CUI dialog.





That's it. Now if you double click on the title block, it will open the Enhanced Attribute Editor dialog and for all other attributed blocks, it will open Edit Attributes dialog. By the way, don't forget to take a backup of the default CUI files before you start experimenting with them.

No comments: