Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys.
I'm trying to write a code to Civil 3D that can add a property set to DBObjects in my Document, and until now i have this:
[CommandMethod("ADDPP")]
public static void AddPropertySet()
{
Database acDBase = Application.DocumentManager.MdiActiveDocument.Database;
using (var propDic = new DictionaryPropertySetDefinitions(acDBase))
{
using (Transaction trans = acDBase.TransactionManager.StartTransaction())
{
var propSetDef = new PropertySetDefinition();
var PropDef = new PropertyDefinition();
PropDef.Name = "name";
PropDef.DefaultData = "value";
propSetDef.Definitions.Add(PropDef);
propDic.AddNewRecord("test", propSetDef);
trans.AddNewlyCreatedDBObject(propSetDef, true);
BlockTable bTb = trans.GetObject(acDBase.BlockTableId, OpenMode.ForWrite) as BlockTable;
BlockTableRecord bTbR = trans.GetObject(bTb["a"], OpenMode.ForWrite) as BlockTableRecord;
PropertyDataServices.AddPropertySet(bTbR, propSetDef.ObjectId);
trans.Commit();
}
}
}
The code add a PropertySetDefinition in my drawing an also add a Property inside that... But the problem is when i try to attach the PPset in my Object, here:
BlockTable bTb = trans.GetObject(acDBase.BlockTableId, OpenMode.ForWrite) as BlockTable;
BlockTableRecord bTbR = trans.GetObject(bTb["a"], OpenMode.ForWrite) as BlockTableRecord;
PropertyDataServices.AddPropertySet(bTbR, propSetDef.ObjectId);
There is no compile error, but when i check my drawing and my named "a" block, i can't see the property set added here:
I don't know where i wrong... Is there something like a "synchronize" to the propertys appears in my block?
Thanks again 🙂
Solved! Go to Solution.