Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Forums,
I'm trying to work with "GetOffsetCurves()" in order to create a offset polyline(opened), but it return a DBObjectCollection. To convert this collections, I put a function :
public Polyline ConvertDBObjectToPolyline(Document doc, DBObjectCollection dbcol, Plane _plane)
{
Polyline _Pline = new Polyline();
Database db = doc.Database;
Transaction tr =doc.TransactionManager.StartTransaction();
using (tr)
{
BlockTable bt =(BlockTable)tr.GetObject(db.BlockTableId,OpenMode.ForWrite);
BlockTableRecord btr =(BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
// For initial Curve take the first in the list
Curve cv1 = dbcol[0] as Curve;
_Pline.AddVertexAt(_Pline.NumberOfVertices, cv1.StartPoint.Convert2d(_plane), BulgeFromCurve(cv1, false), 0, 0);
_Pline.AddVertexAt(_Pline.NumberOfVertices, cv1.EndPoint.Convert2d(_plane), 0, 0, 0);
dbcol.Remove(cv1);
Point3d nextPt = cv1.EndPoint;
int prevCnt = dbcol.Count + 1;
while (dbcol.Count > 0 && dbcol.Count < prevCnt)
{
prevCnt = dbcol.Count;
foreach (Curve cv in dbcol)
{
// If one end of the curve connects with the
// point we're looking for...
if (cv.StartPoint == nextPt || cv.EndPoint == nextPt)
{
// Calculate the bulge for the curve and
// set it on the previous vertex
double bulge = BulgeFromCurve(cv,false);
_Pline.SetBulgeAt(_Pline.NumberOfVertices - 1, bulge);
// Reverse the points, if needed
if (cv.StartPoint == nextPt)
nextPt = cv.EndPoint;
else
// cv.EndPoint == nextPt
nextPt = cv.StartPoint;
// Add out new vertex (bulge will be set next
// time through, as needed)
_Pline.AddVertexAt(_Pline.NumberOfVertices, nextPt.Convert2d(_plane), 0, 0, 0);
// Remove our curve from the list, which
// decrements the count, of course
dbcol.Remove(cv);
break;
}
}
}
tr.Commit();
}
return _Pline;
}
After debugging, it's doesn't march in all segments!
Solved! Go to Solution.