← Inbox

C3D-0170 · Re-insert the title block and fill it for 260714 [PUT-TB-BACK] done

Re-inserts SS_BLOCK_11X17 into paper space at its original position 10.8150,0.2874 on layer BLOCK_TB2 and attaches every attribute from the updated definition with the job 260714 values, including the flood note fields carrying their connecting words. Idempotent - fills an existing insert rather than adding a second.

Script file
C3D-0170.cs
Target
260714 · paper space
Author
claude
Approved
yes · reviewer
Timeout
240s

C# payload

// Re-insert the title block into paper space at its original position and fill every attribute
// for job 260714. The previous insert was erased; the definition is already the updated one
// (13 attribute definitions, including the flood note fields).
//
// Position 10.8150,0.2874 scale 1 rotation 0 - the coordinates the original insert occupied.
// Layer BLOCK_TB2, matching the original.
//
// Flood values carry the connecting words so panel / date / zone read as one sentence:
//   "...COMMUNITY PANEL NO. 13113C0155E, EFFECTIVE SEPTEMBER 26, 2008, AND LIES IN ZONE X."
//
// Idempotent: if an SS_BLOCK_11X17 reference already exists, this fills it rather than adding a
// second one.
const string BLOCK = "SS_BLOCK_11X17";
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
Log("drawing: " + Db.Filename);
if (!bt.Has(BLOCK)) { Log("ABORT: " + BLOCK + " definition missing"); return; }

var want = new Dictionary<string,string>();
want["JOB_NO"]               = "JOB NO.: 260714";
want["SITE_ADDRESS"]         = "285 Huckaby Rd, Brooks, GA 30205, USA";
want["COUNTY"]               = "COUNTY: Fayette";
want["LAND_LOT"]             = "LAND LOT: 124";
want["DISTRICT"]             = "DISTRICT: 4th";
want["DATE"]                 = "DATE: 08/13/26";
want["SURVEY_TYPE"]          = "Boundary Survey";
want["PREP_FOR"]             = "JOY EWING";
want["REF_DB_PG"]            = "REF DB 5857 Page 692";
want["SUBDIVISION_NAME_LOT"] = "";
want["FIRM_PANEL"]           = "13113C0155E, EFFECTIVE";
want["FIRM_DATE"]            = "SEPTEMBER 26, 2008, AND LIES IN ZONE";
want["FLOOD_ZONE"]           = "X.";

var ps = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForWrite);

// already there?
BlockReference existing = null;
foreach (ObjectId id in ps) {
    var b = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
    if (b != null && b.Name == BLOCK) { existing = (BlockReference)Tx.GetObject(id, OpenMode.ForWrite); break; }
}

BlockReference br;
if (existing != null) {
    br = existing;
    Log("existing insert found at " + br.Position.X.ToString("F4") + "," + br.Position.Y.ToString("F4") + " - filling it");
} else {
    br = new BlockReference(new Point3d(10.8150, 0.2874, 0.0), bt[BLOCK]);
    br.Layer = "BLOCK_TB2";
    ps.AppendEntity(br);
    Tx.AddNewlyCreatedDBObject(br, true);
    Log("inserted " + BLOCK + " at 10.8150,0.2874 on layer BLOCK_TB2");
}

// build the attribute collection from the definition
var defBtr = (BlockTableRecord)Tx.GetObject(bt[BLOCK], OpenMode.ForRead);
foreach (ObjectId aid in br.AttributeCollection) {
    var old = (AttributeReference)Tx.GetObject(aid, OpenMode.ForWrite);
    old.Erase();
}
int n = 0;
foreach (ObjectId id in defBtr) {
    var ad = Tx.GetObject(id, OpenMode.ForRead) as AttributeDefinition;
    if (ad == null || ad.Constant) continue;
    var ar = new AttributeReference();
    ar.SetAttributeFromBlock(ad, br.BlockTransform);
    ar.TextString = want.ContainsKey(ad.Tag) ? want[ad.Tag] : ad.TextString;
    br.AttributeCollection.AppendAttribute(ar);
    Tx.AddNewlyCreatedDBObject(ar, true);
    n++;
    Log(String.Format("   {0,-22} = \"{1}\"", ad.Tag, ar.TextString));
}
Log("");
Log("attributes attached: " + n);

// verify by re-reading paper space
int refs = 0;
foreach (ObjectId id in ps) {
    var b = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
    if (b != null && !b.IsErased && b.Name == BLOCK) refs++;
}
Log(BLOCK + " references in paper space: " + refs + " (verified)");
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd.dwg
Message
Executed C3D-0170 (0 entities touched).
Entities
Duration
432 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd.dwg
inserted SS_BLOCK_11X17 at 10.8150,0.2874 on layer BLOCK_TB2
   JOB_NO                 = "JOB NO.: 260714"
   SITE_ADDRESS           = "285 Huckaby Rd, Brooks, GA 30205, USA"
   REF_DB_PG              = "REF DB 5857 Page 692"
   LAND_LOT               = "LAND LOT: 124"
   DISTRICT               = "DISTRICT: 4th"
   COUNTY                 = "COUNTY: Fayette"
   DATE                   = "DATE: 08/13/26"
   SUBDIVISION_NAME_LOT   = ""
   PREP_FOR               = "JOY EWING"
   SURVEY_TYPE            = "Boundary Survey"
   FIRM_PANEL             = "13113C0155E, EFFECTIVE"
   FIRM_DATE              = "SEPTEMBER 26, 2008, AND LIES IN ZONE"
   FLOOD_ZONE             = "X."

attributes attached: 13
SS_BLOCK_11X17 references in paper space: 1 (verified)

Notes

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

No notes yet.