C3D-0323 · 260714 Huckaby R2: fix the giant perpendicular zigzags done
AMZIGZAG swings +-112 shape units vertically vs ~275 horizontally, so at shape scale 0.150 each zigzag became a spike wider than the easement. Drops the shape scale to 0.012, resizes the pattern to a 150-unit repeat so it reads as ~15 ft at the users LinetypeScale of 0.1, and puts all 4 centrelines on 0.1 (three were still on 40). Verifies the dash definition, computed amplitude and repeat, and each entity.
C# payload
// Fix the giant perpendicular zigzags.
//
// AMZIGZAG (shape 135 in ltypeshp.shx) is defined as
// 9,(108,0),(15,56),(30,-112),(15,56),(107,0),(0,0),0
// so it swings +-112 shape-units vertically against ~275 horizontally. At shape scale 0.150 with
// the entity LinetypeScale multiplying on top, each zigzag became a spike taller than the
// easement is wide - which is exactly what the screenshot shows.
//
// Two changes:
// 1. shape scale 0.150 -> 0.012, so the squiggle amplitude is a fraction of the pattern length
// instead of many times it
// 2. every centreline to LinetypeScale 0.1 - the user already set that on 20C9D and confirmed
// it is the value that shows; the other three were still on 40
//
// The dash lengths are also brought down so the pattern repeats sensibly at 0.1: with patLen
// 0.75 and ltscale 0.1 the repeat is 0.075 ft, far too tight, so the pattern is scaled up to
// give roughly a 15 ft repeat at the user's 0.1.
const string LTNAME = "OVERHEAD_POWER";
const string LAYER = "SS-V-POWER-CL";
const double LTS = 0.1;
Log("drawing: " + Db.Filename);
var ltt = (LinetypeTable)Tx.GetObject(Db.LinetypeTableId, OpenMode.ForWrite);
if (!ltt.Has(LTNAME)) { Log(LTNAME + " missing"); return; }
var tst = (TextStyleTable)Tx.GetObject(Db.TextStyleTableId, OpenMode.ForRead);
ObjectId shapeStyle = ObjectId.Null;
foreach (ObjectId id in tst) {
var ts = (TextStyleTableRecord)Tx.GetObject(id, OpenMode.ForRead);
if (ts.IsShapeFile && ts.FileName.IndexOf("ltypeshp", StringComparison.OrdinalIgnoreCase) >= 0) { shapeStyle = id; break; }
}
if (shapeStyle.IsNull) { Log("no ltypeshp.shx shape style"); return; }
// pattern sized so that at ltscale 0.1 the repeat is ~15 ft on the ground
var r = (LinetypeTableRecord)Tx.GetObject(ltt[LTNAME], OpenMode.ForWrite);
r.Comments = "Overhead power ---/\\/\\---/\\/\\---";
r.PatternLength = 150.0;
r.NumDashes = 3;
r.SetDashLengthAt(0, 60.0);
r.SetDashLengthAt(1, -30.0);
r.SetShapeStyleAt(1, shapeStyle);
r.SetShapeNumberAt(1, 135);
r.SetShapeScaleAt(1, 0.012); // was 0.150 - that is what made the spikes
r.SetShapeOffsetAt(1, new Vector2d(-30.0, 0.0));
r.SetShapeRotationAt(1, 0.0);
r.SetShapeIsUcsOrientedAt(1, false);
r.SetDashLengthAt(2, 60.0);
{
var back = (LinetypeTableRecord)Tx.GetObject(ltt[LTNAME], OpenMode.ForRead);
Log(string.Format("{0}: dashes={1} patLen={2:F2}", back.Name, back.NumDashes, back.PatternLength));
for (int i = 0; i < back.NumDashes; i++) {
int shp=0; double sc=0; Vector2d off=new Vector2d();
try { shp=back.ShapeNumberAt(i); } catch {}
try { sc=back.ShapeScaleAt(i); } catch {}
try { off=back.ShapeOffsetAt(i); } catch {}
Log(string.Format(" dash{0} len={1,8:F2} shape={2} scale={3:F4} offset=({4:F2},{5:F2})",
i, back.DashLengthAt(i), shp, sc, off.X, off.Y));
}
Log(string.Format(" amplitude at scale {0:F4}: ~{1:F2} ft (AMZIGZAG swings +-112 units)",
0.012, 112.0 * 0.012 * LTS));
Log(string.Format(" repeat at ltscale {0:F2}: {1:F2} ft", LTS, back.PatternLength * LTS));
}
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
int n = 0;
foreach (ObjectId id in ms) {
var probe = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (probe == null || !probe.Layer.Equals(LAYER, StringComparison.OrdinalIgnoreCase)) continue;
var w = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForWrite);
w.LinetypeId = Db.ByLayerLinetype;
w.LinetypeScale = LTS;
n++;
var back = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForRead);
var line = back as Line;
Log(string.Format(" [{0}] ltscale={1:F2} len={2:F1} -> ~{3:F0} squiggles (verified)",
back.Handle, back.LinetypeScale, line != null ? line.Length : 0.0,
line != null ? line.Length / (150.0 * LTS) : 0.0));
}
Log("");
Log(string.Format("shape scale 0.150 -> 0.012, all {0} centrelines on ltscale {1:F2}", n, LTS));
Ed.Regen();
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg OVERHEAD_POWER: dashes=3 patLen=150.00 dash0 len= 60.00 shape=0 scale=1.0000 offset=(0.00,0.00) dash1 len= -30.00 shape=135 scale=0.0120 offset=(-30.00,0.00) dash2 len= 60.00 shape=0 scale=1.0000 offset=(0.00,0.00) amplitude at scale 0.0120: ~0.13 ft (AMZIGZAG swings +-112 units) repeat at ltscale 0.10: 15.00 ft [20C9D] ltscale=0.10 len=893.0 -> ~60 squiggles (verified) [20C9E] ltscale=0.10 len=364.6 -> ~24 squiggles (verified) [20CA9] ltscale=0.10 len=1514.6 -> ~101 squiggles (verified) [20CB1] ltscale=0.10 len=1569.6 -> ~105 squiggles (verified) shape scale 0.150 -> 0.012, all 4 centrelines on ltscale 0.10
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.