C3DO-0816 · proposed line: read what draws 527-538-539 (read-only) [C3D-P1READ] done
Read-only: every curve and label along points 527 -> 538 -> 539, their layers, plot/freeze state and viewport freezes.
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; }
// read-only: everything drawn along 527 -> 538 -> 539, and how each one plots
var P527=new Point3d(2205260.785,1206969.705,0); var P538=new Point3d(2205758.849,1207204.963,0); var P539=new Point3d(2206376.506,1207212.913,0);
var samples=new List<(string seg,Point3d p)>();
foreach(var t in new[]{0.1,0.3,0.5,0.7,0.9}){ samples.Add(("527-538",P527+(P538-P527)*t)); samples.Add(("538-539",P538+(P539-P538)*t)); }
var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead);
string LInfo(string name){ var r=(LayerTableRecord)Tx.GetObject(lt[name],OpenMode.ForRead); var ltr=(LinetypeTableRecord)Tx.GetObject(r.LinetypeObjectId,OpenMode.ForRead); return (r.IsOff?"OFF ":"on ")+(r.IsFrozen?"FROZEN ":"")+(r.IsPlottable?"plot ":"NOPLOT ")+"c"+r.Color.ColorIndex+" lt "+ltr.Name; }
// viewport-frozen layers per layout
var vpFrozen=new Dictionary<ObjectId,List<string>>();
var dict=(DBDictionary)Tx.GetObject(Db.LayoutDictionaryId,OpenMode.ForRead);
foreach(DBDictionaryEntry de in dict){ var lay=(Layout)Tx.GetObject(de.Value,OpenMode.ForRead); if(lay.ModelType) continue;
var btr=(BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId,OpenMode.ForRead); int i=0;
foreach(ObjectId id in btr){ if(Tx.GetObject(id,OpenMode.ForRead) is Viewport vp){ if(i++==0) continue; var fl=new List<string>(); foreach(ObjectId fid in vp.GetFrozenLayers()){ fl.Add(((LayerTableRecord)Tx.GetObject(fid,OpenMode.ForRead)).Name); } Log("VP "+lay.LayoutName+" "+vp.Handle+" scale 1:"+F(1/vp.CustomScale)+" vp-frozen: "+string.Join(",",fl)); } } }
foreach(ObjectId id in MS){
var e=Tx.GetObject(id,OpenMode.ForRead) as Curve; if(e==null) continue;
var hit=new HashSet<string>();
foreach(var s in samples){ try{ var c=e.GetClosestPointTo(s.p,false); if(c.DistanceTo(s.p)<0.05) hit.Add(s.seg); }catch{} }
if(hit.Count==0) continue;
string ltn=e.Linetype; string extra="";
if(e is Polyline pl){ extra=" n"+pl.NumberOfVertices+(pl.Closed?" closed":"")+" area "+F(pl.Closed?pl.Area:0); }
Log(e.GetType().Name+" "+e.Handle+" ["+e.Layer+": "+LInfo(e.Layer)+"] entity-lt "+ltn+" covers "+string.Join("+",hit.OrderBy(x=>x))+extra);
}
// labels near the line (parcel segment labels, text)
foreach(ObjectId id in MS){ var e=Tx.GetObject(id,OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; if(e==null||e is Curve) continue;
if(!(e is Autodesk.Civil.DatabaseServices.ParcelSegmentLabel || e is MText || e is DBText || e is Autodesk.Civil.DatabaseServices.GeneralSegmentLabel)) continue;
Extents3d ex; try{ ex=e.GeometricExtents; }catch{ continue; }
var c=new Point3d((ex.MinPoint.X+ex.MaxPoint.X)/2,(ex.MinPoint.Y+ex.MaxPoint.Y)/2,0);
double d1=new Line(P527,P538).GetClosestPointTo(c,false).DistanceTo(c), d2=new Line(P538,P539).GetClosestPointTo(c,false).DistanceTo(c);
if(Math.Min(d1,d2)>40) continue;
string txt=e is MText m?m.Contents:(e is DBText t?t.TextString:"");
Log("LABEL "+e.GetType().Name+" "+e.Handle+" ["+e.Layer+": "+LInfo(e.Layer)+"] near "+(d1<d2?"527-538":"538-539")+" "+F(Math.Min(d1,d2))+"' "+txt.Replace("\\P"," / "));
}
Result
Log
VP 17X11 20E73 scale 1:200 vp-frozen: PARCEL,LABELS,C-PROP-LINE,SS-BOUNDARY RED,FLOOD-2013-FUTURE-100YR VP 22X17 (2) 23747 scale 1:200 vp-frozen: PARCEL,LABELS,SS-BOUNDARY RED VP COVER 225C6 scale 1:200 vp-frozen: PARCEL,LABELS,SS-BOUNDARY RED
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.