← Inbox

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.

Script file
C3D-SCALESET.cs
Target
SS_Outfall_260612_SHEET.dwg · model space
Author
claude
Approved
yes · reviewer
Timeout
60s

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

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\SS_Outfall_260612_SHEET.dwg
Message
Executed C3D-SCALESET (0 entities touched).
Entities
Duration
530 ms
Civil 3D
25.0.0.0

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.