Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
How to get an actual Value of a object's PropertySetDefinition?
I thought it is this method:
GetValue(int propertyId, Autodesk.AutoCAD.DatabaseServices.ObjectId id, Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection blockRefPath)
but it is causing Civil3d to crash with fatal error "unhandled access violation reading 0x0000 exception at autocad"
Here is my code so far:
[CommandMethod("PropSets")]
public void PropSets()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
CivilDocument doc = CivilApplication.ActiveDocument;
// select a TIN surface
PromptEntityOptions opSelSurface = new PromptEntityOptions("\nSelect a TIN Surface: ");
opSelSurface.SetRejectMessage("\nOnly TIN Surface is allowed");
opSelSurface.AddAllowedClass(typeof(TinSurface), true);
opSelSurface.AppendKeywordsToMessage = true;
PromptEntityResult resSelSurface = ed.GetEntity(opSelSurface);
ObjectId surfaceId = resSelSurface.ObjectId;
Database db = Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction transsrc=db.TransactionManager.StartTransaction())
{
TinSurface surface = transSrc.GetObject(surfaceId, OpenMode.ForWrite) as TinSurface;
ObjectIdCollection plinePropSetDefs = PropertyDataServices.GetPropertySetDefinitionsUsed(surface);
foreach (ObjectId plinePropSetDef in plinePropSetDefs)
{
var prop = transSrc.GetObject(plinePropSetDef, OpenMode.ForWrite) as PropertySetDefinition;
foreach(PropertyDefinition propDef in prop.Definitions)
{
ObjectIdCollection idsDummy = new ObjectIdCollection();
string val = propDef.Description;
try
{
string propsetdef = prop.GetValue(propDef.Id, surfaceId, plinePropSetDefs).ToString();
Application.ShowAlertDialog("Surface property set def: " + propDef.Name.ToString() + propsetdef);
}
catch (Exception ex)
{
Application.ShowAlertDialog(ex.Message);
}
}
}
}
}
Solved! Go to Solution.