One of our
valued Civil 3D customer and application developer had asked the following question:
I am trying to set the value of the existing userdefined
property "Address" of Parcels using the com method SetUserDefinedPropertyValue
but have had no luck…..
If you have the same question and looking for a solution
using the SetUserDefinedPropertyValue() API, here you go :
//start a transaction
using (Transaction trans = db.TransactionManager.StartTransaction())
{
//get the list of properties
Autodesk.AECC.Interop.Land.AeccUserDefinedPropertyClassification parcelUDPClass =
aeccDb.ParcelUserDefinedPropertyClassifications.Item(0);
//get one property - create or access
Autodesk.AECC.Interop.Land.AeccUserDefinedProperty propItem;
if (parcelUDPClass.UserDefinedProperties.Count == 0)
{
//create a new property
propItem = propItem = parcelUDPClass.UserDefinedProperties.Add("Address", "DESC",
Autodesk.AECC.Interop.Land.AeccUDPPropertyFieldType.aeccUDPPropertyFieldTypeInteger,
true, false, 10, true, false, 20, true, 15, null);
}
else
//or access an existing one
propItem = parcelUDPClass.UserDefinedProperties.Item(0);
//apply classification changes
aeccDb.Sites.Item(0).Parcels.Properties.SetUserDefinedPropertyClassification(
Autodesk.AECC.Interop.Land.AeccUDPClassificationApplyWay.aeccUDPClassificationApplyAll, "Unclassified");
//assuming the drawing contain at least one site, with at least one parcel
if (aeccDb.Sites.Item(0).Parcels.Count > 0)
{
Autodesk.AECC.Interop.Land.AeccParcel parcel = aeccDb.Sites.Item(0).Parcels.Item(0);
//get the property by name
object value = parcel.GetUserDefinedPropertyValue(propItem.Name);
//also the SET the value
parcel.SetUserDefinedPropertyValue(propItem.Name, 13);
}
trans.Commit();
}
Here is the result of running the above code snippet:
Hope this helps!


Leave a Reply