Friday, November 13, 2009

(IV) New SDO_GEOMETRY <-> Autodesk Map3d 2010

Author: Jonio, Dennis

Before I begin to discuss additional detail I will briefly illustrate what it looks like to materialize an Autodesk/Map3d object from a NetSdoGeometry.sdogeometry with this approach. The other class DrawAbleDwg shown below has not been discussed at all to this point. This is in fact the simplest pattern that can be used when dealing with the MULTI type.
Source code (C#):

using MDADDrawAbles;
using MDADDrawAbleDwg;
using DDwg = MDADDrawAbleDwg.DrawAbleDwg;

DrawAbleSdoGeometry D_sdo = new DrawAbleSdoGeometry(some_sdogeometry);
foreach (DrawAble d in D_sdo.Drawables)
{
object aObj = DDwg.DrawAbleDwgObj(d);

if (aObj is Autodesk.AutoCAD.DatabaseServices.MPolygon)
{
DDwg.AddMPolygon(aObj as MPolygon, 5, "MPolygon", "a polygon");
}
else if (aObj is Autodesk.AutoCAD.DatabaseServices.Polyline)
{
DDwg.AddPline(aObj as Polyline, 6, "Polyline", "a polyline");
}
else if (aObj is Autodesk.AutoCAD.DatabaseServices.DBPoint)
{
DDwg.AddPointd(aObj as DBPoint, 4, "Point", "a point");
}
}

The following illustrates just the opposite, a NetSdoGeometry.sdogeometry from multiple Autodesk/Map3d objects. The three(3) in this case will capture the Z axis. Actually I don't know what I am going to do with it but I have it if it is necessary.
Source code (C#):

DrawAble d3 = null;
PromptSelectionOptions pso = new PromptSelectionOptions();
pso.MessageForAdding = "\nEntities must be MPolygons, Polylines, Arc, Circles or Points.";
pso.AllowDuplicates = false;
pso.AllowSubSelections = false;
pso.SingleOnly = false;

PromptSelectionResult psr = ed.GetSelection(pso, MakeFilter());
if (psr.Status == PromptStatus.OK)
{
List drawList = new List();

using (Transaction tr = db.TransactionManager.StartTransaction())
{
foreach (SelectedObject seleobj in psr.Value)
{
Entity ent;
Entity entdb = (Entity)tr.GetObject(seleobj.ObjectId, OpenMode.ForRead);
//Other stuff
ent = entdb;
Polyline pl = ent as Polyline;
Polyline2d pl2d = ent as Polyline2d;
Polyline3d pl3d = ent as Polyline3d;
Arc anArc = ent as Arc;
DBPoint dbPoint = ent as DBPoint;
MPolygon mpoly = ent as MPolygon;
Line line = ent as Line;
Circle circ = ent as Circle;
if (line == null && pl == null && pl2d == null && pl3d == null && anArc == null
&& dbPoint == null && mpoly == null && circ == null)
{
}
else
{

if (pl != null)
{
d3 = DDwg.LineCurveDrawAbleFromPolyline(pl, null, null, 3);
}
if (pl2d != null)
{
d3 = DDwg.LineCurveDrawAbleFromPolyline(null, pl2d, null, 3);
}
if (pl3d != null)
{
d3 = DDwg.LineCurveDrawAbleFromPolyline(null, null, pl3d, 3);
}
if (mpoly != null)
{
d3 = DDwg.PolygonDrawAbleFromMPolygon(mpoly, 3);
}
if (anArc != null)
{
d3 = DDwg.LineCurveDrawAbleFromArc(anArc, 3);
}
if (line != null)
{
d3 = DDwg.LineCurveDrawAbleFromLine(line, 3);
}
if (dbPoint != null)
{
d3 = DDwg.PointDrawAbleFromPoint(dbPoint, 3);
}
if (circ != null)
{
d3 = DDwg.LineCurveDrawAbleFromCircle(circ, 3);
}

}
drawList.Add(d3);
}//foreach object in the selection set
}//using transaction

sdogeometry geometry = DrawAbleSdoGeometryUtil.SdoGeometryFromDrawAble(drawList, 0, 2236);

}//prompt stat OK

DrawAbleSdoGeometryUtil.SdoGeometryFromDrawAble(drawList, 0, 2236); Passing in the DrawAble, the LRS, and the SRID produces a sdogeometry!

Here is the list of things that remain to be shown:
  • Given a NetSdoGeometry.sdogeometry decompose it into a “DrawAble(s)”.
  • Given some “DrawAble(s)” compose a NetSdoGeometry.sdogeometry.
  • Given one or more Autodesk/Map3d objects decompose it(them) into “Drawable(s)”.
  • Given a “DrawAble” compose a Autodesk/Map3d object.
    To be continued ...
  • No comments:

    Post a Comment