Hello All,
I need to update the user defined property values using C# code,
I can see information on how to ge the values of UDP but cannot see any information on how to modify, edit, udpate or add infromation to the UDP of a point.
Basically in the attached image i want to add "Street light" to the Type UDP.
Please advice
Solved! Go to Solution.
Solved by Partha.Sarkar. Go to Solution.
Solved by Jeff_M. Go to Solution.
Hi Raghulan,
You can use CogoPoint.SetUDPValue
You can see some related code snippet in ADN IM DevBlog -
http://adndevblog.typepad.com/infrastructure/2012/08/set-parcel-userdefined-property-from-api.html
Let me know if you have an issue using CogoPoint.SetUDPValue() API Hope this helps !
Cheers,
Partha
Here is the code to help someone else
------------------------------------------------
public static void udpate_UDP(CogoPoint cogoPoint, string udp_classification, string ud_prop, string value) { try { UDPClassification udp_class = set_udp_class(udp_classification); if (udp_class != null) { UDPString udp_string = null; Global.variables.ed.WriteMessage("\nClassfication: " + udp_class.Name); foreach (UDP udp in udp_class.UDPs) { if (udp.Name == ud_prop) { //UDPString udp_string = //udp_string = udp.Name; udp_string = (UDPString)udp; cogoPoint.SetUDPValue(udp_string, value); } } } else { Global.variables.ed.WriteMessage("\nClassfication NOt found or incorrect: " + udp_classification); } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { Global.variables.ed.WriteMessage("\nError : " + ex.Message); } }
public static UDPClassification set_udp_class(string udp_class_set) { UDPClassification udp_class1 = null; try { if (Global.variables.cdoc.PointUDPClassifications.Contains(udp_class_set)) { foreach (UDPClassification udp_class in Global.variables.cdoc.PointUDPClassifications) { if (udp_class.Name == udp_class_set) { udp_class1 = udp_class; } } } else { Global.variables.ed.WriteMessage("\nUDP Classification Dont exists! ", udp_class_set); udp_class1 = null; } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { Global.variables.ed.WriteMessage("\nError : " + ex.Message); } return udp_class1; }