C3D-SCALESET · Replace arch scales with engineering 1"=10'..100' done
Remove architectural scales, add 1"=10' through 1"=100' (by 10s), keep 1"=1'/1:1, set current to 1"=20'. C3D-26.
C# payload
// Replace architectural scales with engineering scales 1"=10'..100' (by 10s).
// paper:drawing for 1"=N' is 1 : (N*12). factor = 1/(N*12).
// Keep '1" = 1'' and '1:1' (generic, not architectural). Set CANNOSCALE to 1"=20' after.
using System;
using System.Linq;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
var db = Db;
var ocm = db.ObjectContextManager;
var coll = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
if (coll == null){ Log("no scale collection"); return; }
var keep = new HashSet<string>(StringComparer.OrdinalIgnoreCase){ "1\" = 1'", "1:1" };
// engineering scales to add: name -> drawing units (paper inches = 1)
var eng = new (string name,double drawing)[]{
("1\" = 10'", 120), ("1\" = 20'", 240), ("1\" = 30'", 360), ("1\" = 40'", 480),
("1\" = 50'", 600), ("1\" = 60'", 720), ("1\" = 70'", 840), ("1\" = 80'", 960),
("1\" = 90'", 1080), ("1\" = 100'", 1200)
};
var engNames = new HashSet<string>(eng.Select(e=>e.name), StringComparer.OrdinalIgnoreCase);
// 1) set CANNOSCALE to a safe generic first so we can delete the current arch one
try {
var one = coll.GetContext("1\" = 1'");
if (one != null) db.Cannoscale = (Autodesk.AutoCAD.DatabaseServices.AnnotationScale)one;
} catch (System.Exception ex) { Log($"cannoscale pre-set note: {ex.Message}"); }
// 2) remove everything that isn't in keep and isn't already an eng scale we want
var toRemove = new List<string>();
foreach (ObjectContext oc in coll)
{
var nm = oc.Name;
if (keep.Contains(nm) || engNames.Contains(nm)) continue;
toRemove.Add(nm);
}
int removed=0;
foreach (var nm in toRemove)
{
try { coll.RemoveContext(nm); removed++; }
catch (System.Exception ex) { Log($" remove '{nm}' note: {ex.Message}"); }
}
Log($"removed {removed} architectural scales");
// 3) add engineering scales (skip if already present)
int added=0;
foreach (var e in eng)
{
if (coll.GetContext(e.name) != null) continue;
try {
var sc = new Autodesk.AutoCAD.DatabaseServices.AnnotationScale{ Name=e.name, PaperUnits=1.0, DrawingUnits=e.drawing };
coll.AddContext(sc);
added++;
} catch (System.Exception ex) { Log($" add '{e.name}' note: {ex.Message}"); }
}
Log($"added {added} engineering scales");
// 4) set current scale to 1"=20'
try {
var s20 = coll.GetContext("1\" = 20'");
if (s20 != null) db.Cannoscale = (Autodesk.AutoCAD.DatabaseServices.AnnotationScale)s20;
} catch (System.Exception ex) { Log($"cannoscale set note: {ex.Message}"); }
// verify
Log("SCALE LIST NOW:");
foreach (ObjectContext oc in coll) Log($" {oc.Name}");
Log($"CANNOSCALE = {db.Cannoscale?.Name}");
Log("DONE.");
Result
Log
removed 16 architectural scales added 10 engineering scales SCALE LIST NOW: 1" = 1' 1" = 90' 1" = 100' 1" = 10' 1" = 20' 1" = 30' 1" = 40' 1" = 50' 1" = 60' 1" = 70' 1" = 80' 1:1 CANNOSCALE = 1" = 20' DONE.
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.