Тема: eAmbiguousOutput

Здравствуйте, коллеги.
Есть вопросы по Autocad .Net API C#.

Мне нужно создать объект, аналог C++ CustomObject, с навороченной логикой построения & редактирования. Решил начать с примера Dragging a Line in Certain Angle. Чтобы усложнить графику, попытался провести еще одну линию со смещением от основной.

private void DrawDragLine(Point3d mousePoint)
{
    ClearTransientGraphics();

    Point3d pt = CalculateEndPoint(mousePoint);

    _dragLine = new Line(_startPoint, pt);
    _dragLine.SetDatabaseDefaults(_db);
    _dragLine.ColorIndex = _colorIndex;
    
    /// начало моей вставки
    try
    {
        DBObjectCollection objects = _dragLine.GetOffsetCurves( 10 ); // <- здесь происходит исключение
        // Autodesk.AutoCAD.Runtime.Exception: eAmbiguousOutput
        // ...
    }
    catch(Exception ex)
    {
        MessageBox.Show( ex.ToString() );
    }
    /// конец моей вставки

    IntegerCollection col = new IntegerCollection();
    TransientManager.CurrentTransientManager.AddTransient(_dragLine, TransientDrawingMode.Highlight, 128, col);

    //whenever the dragged line updated, reset _endPoint
    _endPoint = pt;
}

Ну и собственно вопросы:
1. Почему происходит исключение, из-за чего оно происходит?
2. Насколько сложной может быть графика в TransientManager, какие ограничения существуют?
В документации об этом минимум информации.

Re: eAmbiguousOutput

Разобрался.
Исключение происходит, когда _dragLine.Length равна 0.
TransientManager оказался не при чем.
Тем не менее, если у кого то есть информация про TransientManager и его использование, был бы благодарен.

Re: eAmbiguousOutput

Еще пример, не помню где взял

       // using Autodesk.AutoCAD.GraphicsInterface;

       DBObjectCollection _markers = null;// class member keep it out of the testTransMethod scope



        [CommandMethod("ptBound")]

        public void testTransMethod()
        {

            Document activeDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            Database db = activeDoc.Database;

            Editor ed = activeDoc.Editor;

            PromptEntityOptions peo = new PromptEntityOptions("\nSelect a closed polyline : ");

            peo.SetRejectMessage("Not a polyline");

            peo.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline), true);

            PromptEntityResult per = ed.GetEntity(peo);

            if (per.Status != PromptStatus.OK)

                return;

            ObjectId plOid = per.ObjectId;

            PromptPointResult ppr = ed.GetPoint(new PromptPointOptions("\nSelect an internal point : "));

            if (ppr.Status != PromptStatus.OK)

                return;

            Point3d testPoint = ppr.Value;

            PromptAngleOptions pao = new PromptAngleOptions("\nSpecify ray direction");

            pao.BasePoint = testPoint;

            pao.UseBasePoint = true;

            PromptDoubleResult rayAngle = ed.GetAngle(pao);

            if (rayAngle.Status != PromptStatus.OK)

                return;

            Point3d tempPoint = testPoint.Add(Vector3d.XAxis);

            tempPoint = tempPoint.RotateBy(rayAngle.Value, Vector3d.ZAxis, testPoint);

            Vector3d rayDir = tempPoint - testPoint;

            ClearTransientGraphics();

            _markers = new DBObjectCollection();

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {

                Curve plcurve = tr.GetObject(plOid, OpenMode.ForRead) as Curve;

                for (int cnt = 0; cnt < 2; cnt++)
                {

                    if (cnt == 1)

                        rayDir = rayDir.Negate();

                    using (Ray ray = new Ray())
                    {

                        ray.BasePoint = testPoint;

                        ray.UnitDir = rayDir;

                        Point3dCollection intersectionPts = new Point3dCollection();

                        //plcurve.IntersectWith(  ray,  Intersect.OnBothOperands,  intersectionPts,   IntPtr.Zero,    IntPtr.Zero  );//<--- original code for A2012
                        plcurve.IntersectWith(ray, Intersect.OnBothOperands, intersectionPts, 0, 0);// for A2010

                        foreach (Point3d pt in intersectionPts)
                        {

                            Circle marker = new Circle(pt, Vector3d.ZAxis, 10.0);

                            marker.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 127,255);

                            _markers.Add(marker);

                            IntegerCollection intCol = new IntegerCollection();

                            TransientManager tm = TransientManager.CurrentTransientManager;

                            tm.AddTransient(marker, TransientDrawingMode.Highlight, 128, intCol);

                            ed.WriteMessage("\n" + pt.ToString());
                            

                        }

                    }

                }

                tr.Commit();

            }

        }



        void ClearTransientGraphics()
        {

            TransientManager tm = TransientManager.CurrentTransientManager;

            IntegerCollection intCol = new IntegerCollection();

            if (_markers != null)
            {

                foreach (DBObject marker in _markers)
                {

                    tm.EraseTransient(marker, intCol);

                    marker.Dispose();

                }

            }

        }

Re: eAmbiguousOutput

fixo пишет:

Еще пример, не помню где взял

Спасибо за пример.
Буду разбираться.