C3DO-0818 · proposed property line 527-538-539 dashed + labeled [C3D-P2PROP] done
527->538->539 on new layer SS-BOUNDARY PROPOSED (DASHED4, green) labeled PROPOSED PROPERTY LINE. Closed Tract 1/Tract 2 polylines move unchanged to new no-plot layer SS-BOUNDARY AREAS; open copies of the remaining sides go on SS-BOUNDARY (solid). C-PROP-LINE vp-frozen in 22X17 (2) and COVER (as in 17X11).
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; }
// 527 -> 538 -> 539 plots DASHED as PROPOSED PROPERTY LINE; every other boundary line plots solid.
var P527=new Point2d(2205260.785,1206969.705); var P538=new Point2d(2205758.849,1207204.963); var P539=new Point2d(2206376.506,1207212.913);
var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead);
var dashLt=((LayerTableRecord)Tx.GetObject(lt["SS-BOUNDARY 5AC-C"],OpenMode.ForRead)).LinetypeObjectId;
var propId=Lyr("SS-BOUNDARY PROPOSED",3); var pr=(LayerTableRecord)Tx.GetObject(propId,OpenMode.ForWrite); pr.LinetypeObjectId=dashLt;
var areaId=Lyr("SS-BOUNDARY AREAS",3); var ar=(LayerTableRecord)Tx.GetObject(areaId,OpenMode.ForWrite); ar.IsPlottable=false;
int have=0; foreach(ObjectId id in MS){ if(Tx.GetObject(id,OpenMode.ForRead) is Autodesk.AutoCAD.DatabaseServices.Entity e && e.Layer=="SS-BOUNDARY PROPOSED") have++; }
if(have>0){ Log("SS-BOUNDARY PROPOSED already has "+have+" entities - nothing done"); Ed.Regen(); return; }
bool Same(Point2d a,Point2d b)=>a.GetDistanceTo(b)<0.01;
var t2=(Polyline)Tx.GetObject(H("214A5"),OpenMode.ForWrite); var t1=(Polyline)Tx.GetObject(H("22572"),OpenMode.ForWrite);
double ltsOld=t1.LinetypeScale;
// open copy of a closed ring with the edges 527-538 and 538-539 left out
Polyline Rest(Polyline ring){
int n=ring.NumberOfVertices; int i538=-1; for(int i=0;i<n;i++) if(Same(ring.GetPoint2dAt(i),P538)) i538=i;
if(i538<0) throw new System.Exception("538 not on "+ring.Handle);
int nx=(i538+1)%n, pv=(i538-1+n)%n; // neighbours must be 527 and 539
bool ok=(Same(ring.GetPoint2dAt(nx),P539)&&Same(ring.GetPoint2dAt(pv),P527))||(Same(ring.GetPoint2dAt(nx),P527)&&Same(ring.GetPoint2dAt(pv),P539));
if(!ok) throw new System.Exception("527/538/539 not consecutive on "+ring.Handle);
var p=new Polyline(); int k=0;
for(int s=0;s<n-1;s++){ int i=(nx+s)%n; p.AddVertexAt(k++,ring.GetPoint2dAt(i),s<n-2?ring.GetBulgeAt(i):0,0,0); }
return p; }
var r2=Rest(t2); var r1=Rest(t1);
Put(MS,r2,"SS-BOUNDARY"); Put(MS,r1,"SS-BOUNDARY");
Log("solid rest on SS-BOUNDARY: Tract 2 "+F(r2.Length)+"' ("+r2.NumberOfVertices+" v, "+r2.Handle+"), Tract 1 "+F(r1.Length)+"' ("+r1.NumberOfVertices+" v, "+r1.Handle+")");
string o2=t2.Layer, o1=t1.Layer; t2.Layer="SS-BOUNDARY AREAS"; t1.Layer="SS-BOUNDARY AREAS";
Log("closed rings moved to SS-BOUNDARY AREAS (no plot), areas kept: "+t2.Handle+" "+F(t2.Area)+" sf (was "+o2+"), "+t1.Handle+" "+F(t1.Area)+" sf (was "+o1+")");
var pp=new Polyline(); pp.AddVertexAt(0,P527,0,0,0); pp.AddVertexAt(1,P538,0,0,0); pp.AddVertexAt(2,P539,0,0,0); Put(MS,pp,"SS-BOUNDARY PROPOSED"); pp.LinetypeScale=ltsOld;
Log("proposed line "+F(pp.Length)+"' dashed ("+((LinetypeTableRecord)Tx.GetObject(dashLt,OpenMode.ForRead)).Name+", entity lts "+F(ltsOld)+")");
// labels along each leg, on the Tract 1 side
var styl=((MText)Tx.GetObject(H("2429C"),OpenMode.ForRead)).TextStyleId;
void Lbl(Point2d a,Point2d b,double at){ var v=b-a; var t=v/v.Length; double r=Math.Atan2(t.Y,t.X); if(r>Math.PI/2||r<=-Math.PI/2) r+=Math.PI;
var mid=a+v*at; var side=new Vector2d(t.Y,-t.X); // right of a->b
var c1=(P527+(P539-P527)*0.5); if((mid+side*5-new Point2d(2206000,1207050)).Length > (mid-side*5-new Point2d(2206000,1207050)).Length) side=-side; // toward Tract 1
var p=mid+side*9; var m=new MText{Location=new Point3d(p.X,p.Y,0),Contents="PROPOSED PROPERTY LINE",TextHeight=8,Rotation=r,Attachment=AttachmentPoint.MiddleCenter};
m.SetDatabaseDefaults(Db); m.TextStyleId=styl; m.BackgroundFill=true; m.UseBackgroundColor=true; m.BackgroundScaleFactor=1.15; Put(MS,m,"SS-BOUNDARY PROPOSED"); Log("label at "+F(p.X)+","+F(p.Y)); }
Lbl(P527,P538,0.35); Lbl(P538,P539,0.35);
// parcel segments: confirm every one is traced by the polylines before hiding C-PROP-LINE in the viewports
int miss=0, tot=0; var rings=new[]{t2,t1};
foreach(var h in new[]{"2201F","23115"}){ var c=(Curve)Tx.GetObject(H(h),OpenMode.ForRead); double L=c.GetDistanceAtParameter(c.EndParam);
for(int i=0;i<=200;i++){ var q=c.GetPointAtDist(L*i/200.0); var q0=new Point3d(q.X,q.Y,0); tot++;
bool on=false; foreach(var rg in rings){ var cp=rg.GetClosestPointTo(q0,Vector3d.ZAxis,false); if(Math.Sqrt((cp.X-q0.X)*(cp.X-q0.X)+(cp.Y-q0.Y)*(cp.Y-q0.Y))<0.05){on=true;break;} } if(!on) miss++; } }
Log("parcel-segment samples on the boundary polylines: "+(tot-miss)+"/"+tot);
if(miss==0){ var cid=lt["C-PROP-LINE"]; var col=new ObjectIdCollection{cid};
foreach(var vh in new[]{"23747","225C6"}){ var vp=(Viewport)Tx.GetObject(H(vh),OpenMode.ForWrite); if(!vp.IsLayerFrozenInViewport(cid)) vp.FreezeLayersInViewport(col.GetEnumerator()); Log("C-PROP-LINE vp-frozen in viewport "+vh+": "+vp.IsLayerFrozenInViewport(cid)+" (verified)"); } }
else Log("C-PROP-LINE NOT vp-frozen: parcel segments do not match the polylines");
Ed.Regen();
Result
Log
layer created SS-BOUNDARY PROPOSED layer created SS-BOUNDARY AREAS solid rest on SS-BOUNDARY: Tract 2 5697.349' (7 v, 24903), Tract 1 1387.109' (4 v, 24904) closed rings moved to SS-BOUNDARY AREAS (no plot), areas kept: 214A5 1133440.514 sf (was SS-BOUNDARY), 22572 225021.914 sf (was SS-BOUNDARY 5AC-C) proposed line 1168.539' dashed (DASHED4, entity lts 1) label at 2205438.951,1207043.907 label at 2205975.145,1207198.746 parcel-segment samples on the boundary polylines: 402/402 C-PROP-LINE vp-frozen in viewport 23747: True (verified) C-PROP-LINE vp-frozen in viewport 225C6: True (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.