<CommandMethod("ACANetScheduleLabs")>
Public Sub CreatePropertySetDefinition()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim propSetDefName As String = "ACADoorObjects"
Try
Dim propSetDef As New Autodesk.Aec.PropertyData.DatabaseServices.PropertySetDefinition
propSetDef.SetToStandard(db)
propSetDef.SubSetDatabaseDefaults(db)
propSetDef.Description = "Property Set Definition by ACA.NET"
Dim isStyle As Boolean = False
Dim appliedTo = New Specialized.StringCollection()
appliedTo.Add("AecDbDoor") ' apply to a door object
propSetDef.SetAppliesToFilter(appliedTo, isStyle)
Dim propDefManual = New Autodesk.Aec.PropertyData.DatabaseServices.PropertyDefinition()
propDefManual.SetToStandard(db)
propDefManual.SubSetDatabaseDefaults(db)
propDefManual.Name = "ACAManualProp"
propDefManual.Description = "Manual property by ACA.NET"
propDefManual.DataType = Autodesk.Aec.PropertyData.DataType.Text
propDefManual.DefaultData = "ACA Default"
propSetDef.Definitions.Add(propDefManual)
'Dim propDefAutomatic = New Autodesk.Aec.PropertyData.DatabaseServices.PropertyDefinition()
'propDefAutomatic.SetToStandard(db)
'propDefAutomatic.SubSetDatabaseDefaults(db)
'propDefAutomatic.Name = "ACAWidth"
'propDefAutomatic.Description = "Automatic property by ACA.NET"
'propDefAutomatic.SetAutomaticData("AecDbDoor", "Width")
'propSetDef.Definitions.Add(propDefAutomatic)
'propDefAutomatic = New Autodesk.Aec.PropertyData.DatabaseServices.PropertyDefinition()
'propDefAutomatic.SetToStandard(db)
'propDefAutomatic.SubSetDatabaseDefaults(db)
'propDefAutomatic.Name = "ACAHeight"
'propDefAutomatic.Description = "Automatic property by ACA.NET"
'propDefAutomatic.SetAutomaticData("AecDbDoor", "Height")
'propSetDef.Definitions.Add(propDefAutomatic)
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim dictPropSetDef = New Autodesk.Aec.PropertyData.DatabaseServices.DictionaryPropertySetDefinitions(db)
If dictPropSetDef.Has(propSetDefName, tr) Then
ed.WriteMessage("error - the property set defintion already exists: " & propSetDefName)
Return
End If
dictPropSetDef.AddNewRecord(propSetDefName, propSetDef)
tr.AddNewlyCreatedDBObject(propSetDef, True)
'выбираем объект
Dim opt As PromptEntityOptions = New PromptEntityOptions(vbLf & "Выберите объект: ")
Dim resBlk As PromptEntityResult = Nothing
resBlk = ed.GetEntity(opt)
Dim pvId As ObjectId = resBlk.ObjectId
Dim obj As Autodesk.AutoCAD.DatabaseServices.Entity = tr.GetObject(pvId, OpenMode.ForWrite)
Autodesk.Aec.PropertyData.DatabaseServices.PropertyDataServices.AddPropertySet(obj, propSetDef.Id)
tr.Commit()
End Using
Catch ex As Exception
ed.WriteMessage("error in CreatePropSetDef: " & ex.ToString & vbCrLf)
Return
End Try
ed.WriteMessage("property set definition " & propSetDefName & " is successfully created." & vbCrLf)
End Sub