← Inbox

C3DO-0809 · septic: plot 2005 septic sketch on SS-SEPTIC (285 Huckaby) [C3D-S2DRAW] done

Draw the 2005 Fayette Co. septic sketch (permit 056-05-OSSM-030685): sewer 12' from the rear corner, D.B. 23', 3-run trench 9'/9'/12' ending 8' off the south line, dims, labels and the source note. All on new layer SS-SEPTIC, green.

Script file
C3DO-0809.cs
Target
260714 - 285 Huckaby Rd 22x17.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

string F(double v)=>v.ToString("0.###");
ObjectId H(string h)=>Db.GetObjectId(false,new Handle(Convert.ToInt64(h,16)),0);
ObjectId Lyr(string name,short c){ var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead); if(lt.Has(name)) return lt[name]; lt.UpgradeOpen(); var r=new LayerTableRecord{Name=name,Color=Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci,c)}; var id=lt.Add(r); Tx.AddNewlyCreatedDBObject(r,true); Log("layer created "+name); return id; }
ObjectId Put(BlockTableRecord btr, Autodesk.AutoCAD.DatabaseServices.Entity e, string layer){ e.SetDatabaseDefaults(Db); e.Layer=layer; var id=btr.AppendEntity(e); Tx.AddNewlyCreatedDBObject(e,true); return id; }
var LM=LayoutManager.Current;
BlockTableRecord PS(string name){ var l=(Layout)Tx.GetObject(LM.GetLayoutId(name),OpenMode.ForRead); return (BlockTableRecord)Tx.GetObject(l.BlockTableRecordId,OpenMode.ForWrite); }
var BT=(BlockTable)Tx.GetObject(Db.BlockTableId,OpenMode.ForRead);
var MS=(BlockTableRecord)Tx.GetObject(BT[BlockTableRecord.ModelSpace],OpenMode.ForWrite);
bool HasText(BlockTableRecord btr,string contains){ foreach(ObjectId id in btr){ var o=Tx.GetObject(id,OpenMode.ForRead); if(o is MText m && m.Contents.Contains(contains)) return true; if(o is DBText t && t.TextString.Contains(contains)) return true; } return false; }

// 285 Huckaby: plot the 2005 septic sketch (Fayette Co. Health Dept, permit 056-05-OSSM-030685) on SS-SEPTIC (green).
// Frame: O = house SW (rear) corner, a = along the south wall toward the front (east), d = straight out from the wall (south).
const string L="SS-SEPTIC";
var lid=Lyr(L,3);
int have=0; foreach(ObjectId id in MS){ var e=Tx.GetObject(id,OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; if(e!=null && e.Layer==L) have++; }
if(have>0){ Log("SS-SEPTIC already has "+have+" entities - nothing drawn (idempotent)"); Ed.Regen(); return; }
var O=new Point2d(2206226.902,1207076.391); var SE=new Point2d(2206263.701,1207076.258);
var u=(SE-O)/(SE-O).Length; var n=new Vector2d(u.Y,-u.X);
Point2d P(double a,double d)=>O+u*a+n*d;
Point3d P3(double a,double d){ var p=P(a,d); return new Point3d(p.X,p.Y,0); }
// south line of Tract 1 (SS-BOUNDARY 5AC-C)
var A=new Point2d(2205260.181,1206948.904); var B=new Point2d(2206368.603,1206955.175);
var w=(B-A)/(B-A).Length; var wn=new Vector2d(-w.Y,w.X); // points north (into the tract)
double ToPL(Point2d p)=>(p-A).DotProduct(wn);
double DEnd(double a){ double d0=0, f0=ToPL(P(a,0))-8, d1=200, f1=ToPL(P(a,200))-8; return d0+(d1-d0)*f0/(f0-f1); }
Log("wall-to-south-line at a=12: "+F(ToPL(P(12,0)))+"'");
double aT=-1.5, aM=7.5, aBn=16.5, aBs=19.5, dN=33;
// sewer: wall -> dot -> D.B.
var sw=new Polyline(); sw.AddVertexAt(0,P(12,0),0,0,0); sw.AddVertexAt(1,P(12,23),0,0,0); Put(MS,sw,L);
var dot=new Polyline(); var dc=P(12,5.7); dot.AddVertexAt(0,dc+u*0.35,1,0.7,0.7); dot.AddVertexAt(1,dc-u*0.35,1,0.7,0.7); dot.Closed=true; Put(MS,dot,L);
// D.B. box 2' x 3'
var db=new Polyline(); int k=0; foreach(var v in new[]{P(11,23),P(13,23),P(13,26),P(11,26)}) db.AddVertexAt(k++,v,0,0,0); db.Closed=true; Put(MS,db,L);
var feed=new Polyline(); feed.AddVertexAt(0,P(12,26),0,0,0); feed.AddVertexAt(1,P(aBn,dN),0,0,0); Put(MS,feed,L);
// trench: one serpentine, 3 runs
double eT=DEnd(aT), eM=DEnd(aM), eB=DEnd(aBs);
var tr=new Polyline(); k=0; foreach(var v in new[]{P(aT,eT),P(aT,dN),P(aM,dN),P(aM,eM),P(aBs,eB),P(aBn,dN)}) tr.AddVertexAt(k++,v,0,0,0);
var ltt=(LinetypeTable)Tx.GetObject(Db.LinetypeTableId,OpenMode.ForRead); string lt=ltt.Has("DASHED")?"DASHED":(ltt.Has("HIDDEN")?"HIDDEN":null);
Put(MS,tr,L); if(lt!=null){ tr.Linetype=lt; tr.LinetypeScale=0.5; }
Log("trench "+F(tr.Length)+" LF (report: 300 LF) linetype "+(lt??"continuous")+" ; runs end "+F(eT)+"/"+F(eM)+"/"+F(eB)+"' from wall");
// dims
void Dim(Point2d p1,Point2d p2,Point2d dl){ var d=new AlignedDimension(new Point3d(p1.X,p1.Y,0),new Point3d(p2.X,p2.Y,0),new Point3d(dl.X,dl.Y,0),"",Db.Dimstyle); Put(MS,d,L); d.Dimscale=15; Log("dim "+F(d.Measurement)+"'"); }
Dim(P(0,0),P(12,0),P(6,3));
Dim(P(12,0),P(12,23),P(8,11.5));
Dim(P(aT,dN),P(aM,dN),P(3,dN-3));
Dim(P(aM,dN),P(aBn,dN),P(12,dN-3));
Dim(P(aM,eM),P(aBs,eB),P(13.5,(eM+eB)/2-3));
var cm=P(13.5,(eM+eB)/2); var foot=cm-wn*(ToPL(cm)); Dim(cm,foot,cm+u*4);
// labels
var styl=((MText)Tx.GetObject(H("2429C"),OpenMode.ForRead)).TextStyleId;
void T(Point2d p,string s,double h,AttachmentPoint ap,double width){ var m=new MText{Location=new Point3d(p.X,p.Y,0),Contents=s,TextHeight=h,Attachment=ap,Width=width}; m.SetDatabaseDefaults(Db); m.TextStyleId=styl; m.Rotation=Math.Atan2(u.Y,u.X); Put(MS,m,L); }
T(P(14,24.5),"D.B.",1.5,AttachmentPoint.MiddleLeft,0);
T(P(14,21),"150' TO WELL (PER REPORT)",1.5,AttachmentPoint.MiddleLeft,0);
T(new Point2d(2206205,1207040),@"SEPTIC SYSTEM SHOWN IS PLOTTED FROM THE SKETCH (NOT TO SCALE) ON THE GEORGIA DEPARTMENT OF HUMAN RESOURCES ON-SITE SEWAGE MANAGEMENT SYSTEM INSPECTION REPORT, CONSTRUCTION PERMIT NO. 056-05-OSSM-030685, DATED 7/15/2005, FAYETTE COUNTY HEALTH DEPARTMENT. LOCATION IS APPROXIMATE AND WAS NOT FIELD LOCATED.",4,AttachmentPoint.MiddleRight,110);
// verify
int c=0; var types=new Dictionary<string,int>(); foreach(ObjectId id in MS){ var e=Tx.GetObject(id,OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; if(e!=null && e.Layer==L){ c++; var t=e.GetType().Name; types[t]=types.TryGetValue(t,out var q)?q+1:1; } }
var lr=(LayerTableRecord)Tx.GetObject(lid,OpenMode.ForRead);
Log("SS-SEPTIC color "+lr.Color.ColorIndex+" entities "+c+" : "+string.Join(", ",types.Select(kv=>kv.Key+" "+kv.Value))+" (verified)");
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd 22x17.dwg
Message
Executed C3DO-0809 (0 entities touched).
Entities
—
Duration
796 ms
Civil 3D
25.0.0.0

Log

layer created SS-SEPTIC
wall-to-south-line at a=12: 121.904'
trench 263.882 LF (report: 300 LF) linetype DASHED ; runs end 114.035/113.951/113.84' from wall
dim 12'
dim 23'
dim 9'
dim 9'
dim 12.001'
dim 8'
SS-SEPTIC color 3 entities 14 : Polyline 5, AlignedDimension 6, MText 3 (verified)

Notes

What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.

No notes yet.