May 04, 2006

Retrieving the Door Type of a Door Style

On several occasions, I have responded to questions in the Autodesk Architectural Desktop Discussion Groups regarding whether the Door Type, which you set on the Design Rules tab of the Door Style, is available as an Automatic property type. My responses had always been, "No." It still is not (or so I am told, I have not checked 2007 yet myself), but having recently worked with methods of retrieving data from the drawing file in a Formula property for a class I will be teaching, it occurred to me this evening that I should be able to get the Door Type for a given door using a Formula property. I can report that it is possible, and have done so in ADT 2004, with one limitation: it will not work through external references, only when the Schedule Table is in the same file as the doors. There is an alternate method for users of 2006 and 2007 which should work across external references; I will confirm that in a future article, when I have time to test it.

You can find the sample file that generated the images below in this thread in the Autodesk Architectural Desktop Discussion Group. The sample file contains a Door Style for each of the twenty Door Types that exist in ADT 2004, an instance of each Door Style and a custom Property Set Definition called "DoorStyles4".



The Door Styles were made by copying the Standard door style, attaching the DoorStyles4 Property Set Definition, and setting the Door Type. All other settings remain as per the Standard door style. The DoorStyles4 Property Set Definition has one Automatic property, "Handle", that uses the Handle Automatic Property Source. This allows the other two properties to access the data for each door in the drawing. Those two properties are Formula properties, called "DoorTypeNumber" and "DoorTypeText" and are independent of each other. "DoorTypeNumber" returns the quoted string stored in the Type property of the Door Style of the door. "DoorTypeText" takes that same value and uses a Select Case statement to return the "name" of the Door Type, as shown in the list box on the Design Rules tab.

The "DoorTypeNumber" formula looks something like this:
Set acadApp = GetObject(,"AutoCAD.Application")
Set doorObj = acadApp.ActiveDocument.HandleToObject( "[Handle]" )
Set doorStyle = doorObj.Style
doorTypeInt = doorStyle.Type
RESULT = doorTypeInt


The "DoorTypeText" formula starts out the same, but adds a Select Case statement to return the appropriate text string:
Set acadApp = GetObject(,"AutoCAD.Application")
Set doorObj = acadApp.ActiveDocument.HandleToObject( "[Handle]" )
Set doorStyle = doorObj.Style
doorTypeInt = doorStyle.Type

Select Case doorTypeInt
Case "0"
RESULT = "Custom"
Case "1"
RESULT = "Single"
Case "2"
RESULT = "Double"
Case "3"
RESULT = "Single-Dhung"
Case "4"
RESULT = "Double-Dhung"
Case "5"
RESULT = "Double Opposing"
Case "6"
RESULT = "Uneven"
Case "7"
RESULT = "Uneven-Dhung"
Case "8"
RESULT = "Uneven Opposing"
Case "9"
RESULT = "Bifold"
Case "10"
RESULT = "Bifold Double"
Case "11"
RESULT = "Pocket"
Case "12"
RESULT = "Double Pocket"
Case "13"
RESULT = "Sliding Double"
Case "14"
RESULT = "Sliding Triple"
Case "15"
RESULT = "Overhead"
Case "16"
RESULT = "Revolving"
Case "17"
RESULT = "Pass Thru"
Case "18"
RESULT = "Accordion"
Case "19"
RESULT = "Panel"
Case "20"
RESULT = "Communicating"
Case Else
RESULT = "Unknown Door Type"
End Select


The image below shows the Schedule Table in the sample file that displays the results of the formulas. I tagged each door with the ADT 2004 out-of-the-box, non-project door tag, and set the door numbers equal to the number corresponding to the Door Type.


5/23/2006 Update: Using ADT 2006 or later and need to have this formula work across external references? Have a look at this article.

No comments: