Well, I went back to some code that Jeff put out some place; I thought it might clarify the problem in my head and with you guys.
I believe that what is below will get a single Classification on a single Entity (thanks Jeff) but what I can't understand is how to pull a value off this. I can get as far as finding the ObjectID of exactly one classification on exactly one entity. Very cool.
But now it is not clear to me how to find the assigned value of the Classification. This value is assigned within ACA by the user. As you know, there is no such thing as ObjectID.Value
To be concise - how can I can determine what Category each AecDbSpace has. I can get each AecDbSpace's 'Category', but I can't see where I can read what the actual Category is (eg Building, Block etc)
'many thanks to Jeff H
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports ObjectId = Autodesk.AutoCAD.DatabaseServices.ObjectId
Imports AecDbSrvcs = Autodesk.Aec.DatabaseServices
Imports ArchDbSrvcs = Autodesk.Aec.Arch.DatabaseServices
Imports Autodesk.Aec.PropertyData.DatabaseServices
Imports Autodesk.Aec.DatabaseServices
<Assembly: CommandClass(GetType(MEPExamplesVB.MyCommands))>
Namespace MEPExamplesVB
Public Class MyCommands
<CommandMethod("GetSpaceDataVB")> _
Public Sub GetSpaceDataVB()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Using trx As Transaction = db.TransactionManager.StartTransaction()
Dim mdlSpace As BlockTableRecord = SymbolUtilityServices.GetBlockModelSpaceId(db).GetObject(OpenMode.ForRead)
For Each objId As ObjectId In mdlSpace
If objId.ObjectClass.Name = "AecDbSpace" Then
Dim spce As ArchDbSrvcs.Space = trx.GetObject(objId, OpenMode.ForRead)
Dim Ret_TClass As ObjectId = GetClassifID("Category")
Dim RetrClassID As ObjectId = Autodesk.Aec.DatabaseServices.ClassificationDefinition.GetClassification(spce, Ret_TClass)
'I dont what to do from here. I need to find the value of this Classficiation.
Dim spceStyle As ArchDbSrvcs.SpaceStyle = trx.GetObject(spce.StyleId, OpenMode.ForRead)
'ed.WriteMessage(String.Format("{0}This Space Name: {1} Area: {2} and is on Stlye?: {3}", _
'vbCrLf, spce.Name, spce.Area, spceStyle.Name))
Dim spc_ownerID As ObjectId = spce.OwnerId
If spc_ownerID.ObjectClass.Name = "AecDbSpace" Then
Dim plg As AecDbSrvcs.Polygon = trx.GetObject(spc_ownerID, OpenMode.ForRead)
End If
End If
Next
End Using
End Sub
#Region "GetClassficationId"
'we need to
'takes the AecDbSpace object <id>
'takes the ClassficiationName <TargClasName>
'returns the objectid for the targeted classification
Public Function GetClassifID(ByVal TargClasName As String) As ObjectId
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim TargetClassID As ObjectId
Dim ed As Editor = doc.Editor
Using trx As Transaction = db.TransactionManager.StartTransaction()
Dim classDefDictionary As New DictionaryClassificationDefinition(db)
Dim objectIds As Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection = classDefDictionary.Records
For Each objId As ObjectId In objectIds
Dim classDef As ClassificationDefinition = trx.GetObject(objId, OpenMode.ForRead)
If classDef.AppliesToFilter.Contains("AecDbSpace") Then
'ed.WriteMessage(vbCrLf & classDef.Name)
If classDef.Name = TargClasName Then
TargetClassID = classDef.ObjectId
'GetClassifications(classDef.ClassificationTree)
End If
End If
Next
trx.Commit()
End Using
Return TargetClassID
End Function
#End Region
End Class
End Namespace