C3D-0691 · Set title block JOB_NO to 261102 on 260714 22x17 (test) done
Test requested by the user. Changes JOB_NO from JOB NO.: 260714 to JOB NO.: 261102 on layouts 17X11, 22X17 (2), COVER and COVER (22). Nothing else changes.
C# payload
// Sets the JOB_NO title block attribute on the four sheet layouts. Touches nothing else.
// Idempotent. Any surprise throws, so the host aborts it all.
const string OLD_VALUE = "JOB NO.: 260714";
const string NEW_VALUE = "JOB NO.: 261102";
var layouts = new HashSet<string> { "17X11", "22X17 (2)", "COVER", "COVER (22)" };
var seen = new HashSet<string>();
var ld = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
foreach (DBDictionaryEntry de in ld) {
var lo = (Layout)Tx.GetObject(de.Value, OpenMode.ForRead);
if (!layouts.Contains(lo.LayoutName)) continue;
var btr = (BlockTableRecord)Tx.GetObject(lo.BlockTableRecordId, OpenMode.ForRead);
foreach (ObjectId id in btr) {
var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
if (br == null || br.AttributeCollection.Count == 0) continue;
if (br.Name != "SS_BLOCK_17X11" && br.Name != "SS_BLOCK_22X17_TB") continue;
foreach (ObjectId aid in br.AttributeCollection) {
var a = (AttributeReference)Tx.GetObject(aid, OpenMode.ForRead);
if (a.Tag != "JOB_NO") continue;
if (!seen.Add(lo.LayoutName)) throw new System.Exception("more than one JOB_NO on " + lo.LayoutName);
var old = a.TextString;
if (old == NEW_VALUE) { Log("[" + lo.LayoutName + "] already " + NEW_VALUE); continue; }
if (old != OLD_VALUE) throw new System.Exception("[" + lo.LayoutName + "] unexpected value: " + old);
a.UpgradeOpen();
a.TextString = NEW_VALUE;
if (a.TextString != NEW_VALUE) throw new System.Exception("[" + lo.LayoutName + "] read-back failed: " + a.TextString);
Log("[" + lo.LayoutName + "] JOB_NO: \"" + old + "\" -> \"" + a.TextString + "\" (verified)");
}
}
}
if (seen.Count != 4) throw new System.Exception("expected 4 JOB_NO attributes, found " + seen.Count);
Ed.Regen();Result
Log
[17X11] JOB_NO: "JOB NO.: 260714" -> "JOB NO.: 261102" (verified) [22X17 (2)] JOB_NO: "JOB NO.: 260714" -> "JOB NO.: 261102" (verified) [COVER] JOB_NO: "JOB NO.: 260714" -> "JOB NO.: 261102" (verified) [COVER (22)] JOB_NO: "JOB NO.: 260714" -> "JOB NO.: 261102" (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.