Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I wrote this command method to update all of the parcels in a drawing to use a user-defined property classification, and it works great, but I can't seem to find a method to change the User-defined property classification in the Site Parcel Properties directly? The new UDP does not show up in the Prospector graph view unless it is selected in that dialog. Does anyone know if changing that is possible through the COM/API?
[CommandMethod("SETUDPCLASS")]
public void SetUDPClass()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
CivilDocument civilDoc = CivilApplication.ActiveDocument;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
ObjectIdCollection siteIds = civilDoc.GetSiteIds();
if (siteIds.Count == 0)
{
ed.WriteMessage("\nNo parcel sites found in drawing.");
tr.Commit();
return;
}
int sitesProcessed = 0;
foreach (ObjectId siteId in siteIds)
{
Site site = tr.GetObject(siteId, OpenMode.ForWrite) as Site;
if (site == null) continue;
dynamic comSite = null;
dynamic parcels = null;
dynamic parcelsProperties = null;
try
{
comSite = site.AcadObject;
parcels = comSite.Parcels;
parcelsProperties = parcels.Properties;
parcelsProperties.SetUserDefinedPropertyClassification(0, "LandUse");
ed.WriteMessage($"\nSet UDP classification to 'LandUse' for site: {site.Name}");
sitesProcessed++;
}
catch (System.Exception ex)
{
ed.WriteMessage($"\nError for site {site.Name}: {ex.Message}");
}
finally
{
if (parcelsProperties != null && Marshal.IsComObject(parcelsProperties))
Marshal.ReleaseComObject(parcelsProperties);
if (parcels != null && Marshal.IsComObject(parcels))
Marshal.ReleaseComObject(parcels);
if (comSite != null && Marshal.IsComObject(comSite))
Marshal.ReleaseComObject(comSite);
}
}
ed.WriteMessage($"\n{sitesProcessed} site(s) updated.");
tr.Commit();
}
}
Solved! Go to Solution.