May 23, 2006

Retrieving the Door Type of a Door Style 2

This is a follow up to my previous article on Retrieving the Door Type of a Door Style. The alternate method available to users of 2006 and 2007 mentioned does work across external references; it involves using the ObjectID Automatic Property Source, rather than the Handle Automatic Property Source, as the means for accessing the door object. The following code and images are from a test using ADT 2006. I have yet to find time to install 2007, but expect that it would work there, as well.

I have posted the sample files I used in 2006 in an additional reply to the same thread in the Autodesk Architectural Desktop Discussion Group as before. The sample file contains a modified version of the original file, with an Automatic property for the ObjectID Automatic Property Source and two formula properties, one that returns the Door Type number and one that converts that to the text string used on the Design Rules tab, in the Property Set Definition called "DoorStyles4". There is also a second file that has the sample file attached as an external reference.

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


The "DoorTypeText-ObjectID" 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.ObjectIDToObject( [ObjectID] )
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 file, and shows that both methods work when the objects are in the same file as the Schedule Table.

The Handle-based Formula properties fail when the file with the objects is externally referenced into another file, as you can see in the sample file. The image below shows just the ObjectID-based properties.

9/15/2008 Update: Using this formula in a property assigned to both Doors and Door/Window Assemblies (or any other object type where the object style does not have a type property)? Have a look at this article for how to deal with that situation.

No comments: