Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Civil3D 2013 COGO Point update User defined property value using C#

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
1590 Views, 5 Replies

Civil3D 2013 COGO Point update User defined property value using C#

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.

5-19-2013 11-54-50 AM.png

 

Please advice

5 REPLIES 5
Message 2 of 6
Jeff_M
in reply to: Anonymous

If this doesn't help, show code you are trying.

 

cogopt.SetUDPValue(udpname, udpvalue);

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 6
Anonymous
in reply to: Anonymous

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

 

http://adndevblog.typepad.com/infrastructure/2013/04/civil-3d-net-api-cogo-point-how-to-read-a-user-...

 

Let me know if you have an issue using CogoPoint.SetUDPValue() API Hope this helps !

 

Cheers,

Partha

Message 4 of 6
Anonymous
in reply to: Jeff_M

Thanks Jeff, will try and update!
Message 5 of 6
Anonymous
in reply to: Anonymous

Thanks Partha, Will try and update.
Message 6 of 6
Anonymous
in reply to: Anonymous

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;
        }

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report