Hi Jeff,
I am trying to write a script to do the following.
For each (cogo point in drawing)
{
If (Raw description == THISCODE*)
{
Replace THISCODE with User defined attribute 1
}
applyDescriptionKey()
}
I am running Civil 3D 2013.
Having read through a few of your other threads I noticed that applyDescriptionKey() is 2013 specific.
Cheers,
Sam
Solved! Go to Solution.
Solved by samthomasdigital. Go to Solution.
Solved by Jeff_M. Go to Solution.
Hi Sam,
I hope you don't get used to someone whipping out some quick code but I was actually working on something similar recently so I kindof already had some test code here. This should more than get you started. How fluent are you in C#? You will need to add teh appropriate References and using statements...
private void swapdescforudp(string description, UDPString udp) { CivilDocument civdoc = CivilApplication.ActiveDocument; using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { foreach (ObjectId id in civdoc.GetAllPointIds()) { CogoPoint pt = (CogoPoint)id.GetObject(OpenMode.ForRead); if (pt.RawDescription == description) { try { pt.UpgradeOpen(); pt.RawDescription = pt.GetUDPValue(udp); pt.ApplyDescriptionKeys(); } catch { } finally { pt.DowngradeOpen(); } } } tr.Commit(); } } [CommandMethod("UDPToDesc")] public void udptodesccommand() { string udpname = "TEST"; UDPString udp = null; CivilDocument civdoc = CivilApplication.ActiveDocument; foreach (UDP obj in civdoc.PointUDPs) { if (obj.Name == udpname) { udp = (UDPString)obj; break; } } if (udp == null) return; swapdescforudp("test", udp); }
Hey Jeff,
What you sent me looks excellent! I have some perl knowledge that google taught me but C# looks fairly similar.
I really appreciate the help and I should be able to tweak it myself from here.
I'll let you know how I go.
You're a legend!
Sam
Hey Jeff,
I worked through the Civil 3D API developers guide and got it working! Thanks for the (massive) head start. Much appreciated.
Sam.
Hey Jeff!
I have modified the code so that it takes both attributes 1 and 2 then concatenates them. It was all going great until I realised that I can't access the Survey User-Defined Attributes. I can't find any documentation on this in the developers guide. Do you know if it is possible?
Cheers,
Sam
Hey Jeff,
I had a custom import format file that when I was importing the CSV as survey data Civil 3D was creating another set of attributes Survey User-Defined that I couldn't access through my dll. But...
I found a better way! If I import the points the traditional way then add them to a survey database afterwards I don't get the duplicate attributes and I can use the code you supplied me.
I would have had to modify all the labels styles to include either Attribute 1 or the new one that was created on import Point.Attibute 1 anyway. Painful.
Thanks for the help. Should be all good now.
Sam