C3D-PSATTR · Attach missing block attributes done
Creates AttributeReferences on the SS_BLOCK_22X17 reference from the definitions AttributeDefinitions, so the title block has editable attributes. Lists each tag/prompt/default.
C# payload
// Attach the missing attribute references to the SS_BLOCK_22X17 reference.
// Inserting a BlockReference does NOT instantiate attributes - each AttributeDefinition in the
// definition needs a matching AttributeReference appended to the reference and transformed by
// the reference's BlockTransform. Without this the block reports "no editable attributes".
// Host owns Tx - no using/Commit here.
const string BLK = "SS_BLOCK_22X17", LAYOUT = "22X17 C";
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
if (!bt.Has(BLK)) { Log($"'{BLK}' not defined."); return; }
var def = (BlockTableRecord)Tx.GetObject(bt[BLK], OpenMode.ForRead);
var defs = new List<AttributeDefinition>();
foreach (ObjectId id in def)
{
var ad = Tx.GetObject(id, OpenMode.ForRead) as AttributeDefinition;
if (ad != null && !ad.Constant) defs.Add(ad);
}
Log($"definition has {defs.Count} non-constant AttributeDefinitions:");
foreach (var ad in defs) Log($" tag='{ad.Tag}' prompt='{ad.Prompt}' default='{ad.TextString}'");
if (defs.Count == 0) return;
var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
var layout = (Layout)Tx.GetObject(layDict.GetAt(LAYOUT), OpenMode.ForRead);
var ps = (BlockTableRecord)Tx.GetObject(layout.BlockTableRecordId, OpenMode.ForWrite);
int fixedRefs = 0;
foreach (ObjectId id in ps)
{
var b0 = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
if (b0 == null) continue;
var d0 = (BlockTableRecord)Tx.GetObject(b0.BlockTableRecord, OpenMode.ForRead);
if (d0.Name != BLK) continue;
var br = (BlockReference)Tx.GetObject(id, OpenMode.ForWrite);
int had = br.AttributeCollection.Count;
if (had > 0) { Log($" reference {br.Handle} already has {had} attributes - skipping."); continue; }
var xform = br.BlockTransform;
foreach (var ad in defs)
{
var ar = new AttributeReference();
ar.SetAttributeFromBlock(ad, xform);
ar.TextString = ad.TextString;
br.AttributeCollection.AppendAttribute(ar);
Tx.AddNewlyCreatedDBObject(ar, true);
}
fixedRefs++;
Log($" reference {br.Handle}: attached {br.AttributeCollection.Count} attribute references (verified).");
}
Log($"Fixed {fixedRefs} '{BLK}' reference(s).");
Result
Log
definition has 10 non-constant AttributeDefinitions:
tag='JOB_NO' prompt='JOB NO.: 251002' default='JOB NO.: 251002'
tag='SITE_ADDRESS' prompt='SITE_ADDRESS' default='SITE_ADDRESS'
tag='REF_DB_PG' prompt='REF DB xxx Page xxx' default='REF DB xxx Page xxx'
tag='LAND_LOT' prompt='LAND LOT: ###' default='LAND LOT: ###'
tag='DISTRICT' prompt='DISTRICT: #TH' default='DISTRICT: #TH'
tag='COUNTY' prompt='COUNTY: CLAYCO' default='COUNTY: CLAYCO'
tag='DATE' prompt='DATE: 10/16/25' default='DATE: 10/16/25'
tag='SUBDIVISION_NAME_LOT' prompt='SUBDIVISION_NAME LOT ##' default='SUBDIVISION_NAME LOT ##'
tag='PREP_FOR' prompt='PREP_FOR' default='PREP_FOR'
tag='SURVEY_TYPE' prompt='BOUNDARY SURVEY' default='BOUNDARY SURVEY'
reference 222EB: attached 10 attribute references (verified).
Fixed 1 'SS_BLOCK_22X17' reference(s).Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.