← Inbox

C3DO-0779 · 261101: north line label -> N85°55'02"E 266.48' [C3D-NORTHTXT] error

Block 21BD3 (C-PROP-LINE-TEXT) holds the north line's text 'N86°06'35"E / 268.04''. Change it to 'N85°55'02"E / 266.48'' inside its block definition (only if that block has 1 reference).

Script file
C3DO-0779.cs
Target
261101 - 5491 Roswell Rd NE R2.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

ObjectId rid; Db.TryGetObjectId(new Handle(Convert.ToInt64("21BD3",16)),out rid);
var br=(BlockReference)Tx.GetObject(rid,OpenMode.ForRead);
var def=(BlockTableRecord)Tx.GetObject(br.BlockTableRecord,OpenMode.ForRead);
int nref=def.GetBlockReferenceIds(true,false).Count; Log("block "+def.Name+" refs "+nref);
if(nref!=1){ Log("STOP - block used by "+nref+" refs"); return; }
var rep=new[]{ new[]{"N86\U+00B0 06' 35\"E","N85\U+00B0 55' 02\"E"}, new[]{"N86°06'35\"E","N85°55'02\"E"}, new[]{"N86° 06' 35\"E","N85° 55' 02\"E"}, new[]{"268.04'","266.48'"} };
int n=0;
foreach(ObjectId e in def){ var o=Tx.GetObject(e,OpenMode.ForRead);
 if(o is MText){ var m=(MText)o; string c0=m.Contents, c=c0; foreach(var r in rep) c=c.Replace(r[0],r[1]); Log("MText "+e.Handle+" | "+c0+(c!=c0?" -> "+c:""));
  if(c!=c0){ m.UpgradeOpen(); m.Contents=c; n++; Log("   now | "+m.Contents+" (verified)"); } }
 else if(o is DBText){ var t=(DBText)o; string c0=t.TextString, c=c0; foreach(var r in rep) c=c.Replace(r[0],r[1]); Log("Text "+e.Handle+" | "+c0+(c!=c0?" -> "+c:""));
  if(c!=c0){ t.UpgradeOpen(); t.TextString=c; n++; Log("   now | "+t.TextString+" (verified)"); } } }
if(n!=2){ throw new Exception("expected 2 texts changed, got "+n+" - nothing saved"); }
br.UpgradeOpen(); br.RecordGraphicsModified(true);
Ed.Regen();

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\261101 - Project\261101 - 5491 Roswell Rd NE R2.dwg
Message
Compile error: (6,26): error CS1009: Unrecognized escape sequence; (6,49): error CS1009: Unrecognized escape sequence
Entities
—
Duration
6 ms
Civil 3D
25.0.0.0

Notes

What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.

No notes yet.