Esempio n. 1
0
        handOverPoly3d2(this ObjectId idPoly3dOrg, List <Point3d> pnts3d)
        {
            Database          db         = BaseObjs._db;
            Point3dCollection pnts3dColl = new Point3dCollection();

            foreach (Point3d pnt3d in pnts3d)
            {
                pnts3dColl.Add(pnt3d);
            }

            using (OpenCloseTransaction tr = db.TransactionManager.StartOpenCloseTransaction())
            {
                Polyline3d poly3dOrg = (Polyline3d)tr.GetObject(idPoly3dOrg, OpenMode.ForRead);
                Debug.Print(poly3dOrg.Handle.ToString());

                Polyline3d poly3dNew = new Polyline3d(Poly3dType.SimplePoly, pnts3dColl, false);
                poly3dNew.SetDatabaseDefaults();
                poly3dNew.Layer = poly3dOrg.Layer;

                poly3dOrg.UpgradeOpen();
                poly3dOrg.HandOverTo(poly3dNew, true, true);
                Debug.Print(poly3dOrg.Handle.ToString());
                Debug.Print(poly3dNew.Handle.ToString());
                bool x = poly3dOrg.IsDisposed;
                poly3dOrg.Dispose();

                tr.AddNewlyCreatedDBObject(poly3dNew, true);
                tr.Commit();
            }
        }
Esempio n. 2
0
        handOverPoly3d(this ObjectId idPoly3dOrg, List <Point3d> pnts3d)
        {
            Polyline3d poly3dOrg = (Polyline3d)idPoly3dOrg.Open(OpenMode.ForRead);

            Point3dCollection pnts3dColl = new Point3dCollection();

            foreach (Point3d pnt3d in pnts3d)
            {
                pnts3dColl.Add(pnt3d);
            }

            Polyline3d poly3dNew = new Polyline3d(Poly3dType.SimplePoly, pnts3dColl, false);

            poly3dNew.SetDatabaseDefaults();
            poly3dOrg.UpgradeOpen();
            poly3dOrg.HandOverTo(poly3dNew, true, true);
            poly3dNew.Close();
            poly3dOrg.Dispose();
        }
Esempio n. 3
0
        public void DevelopmentCommand()
        {
            Database arg_05_0 = HostApplicationServices.WorkingDatabase;
            Editor   editor   = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                PromptEntityOptions promptEntityOptions = new PromptEntityOptions("Select polyline");
                promptEntityOptions.SetRejectMessage("\nNo polyline selected");
                promptEntityOptions.AddAllowedClass(typeof(Polyline3d), true);
                promptEntityOptions.AddAllowedClass(typeof(Polyline2d), true);
                promptEntityOptions.AddAllowedClass(typeof(Polyline), true);
                promptEntityOptions.AllowNone = (false);
                PromptEntityResult entity = editor.GetEntity(promptEntityOptions);
                if (entity.Status == (PromptStatus)(-5002))
                {
                    CommandLineQuerries.OnCancelled();
                }
                if (entity.Status != (PromptStatus)5100)
                {
                    CommandLineQuerries.OnNotOK();
                }
                CMD_Development.string_2 = CommandLineQuerries.KeywordYesNo("Reverse polyline", CMD_Development.string_2, false, false);
                CMD_Development.string_3 = CommandLineQuerries.KeywordYesNo("Specify range", CMD_Development.string_3, false, false);
                if (CMD_Development.string_3 == "Y")
                {
                    CMD_Development.double_0 = CommandLineQuerries.SpecifyDouble("Specify start arc length", CMD_Development.double_0, false, false, false, true);
                    CMD_Development.double_1 = CommandLineQuerries.SpecifyDouble("Specify end arc length", CMD_Development.double_1, false, false, false, true);
                }
                CMD_Development.double_2 = CommandLineQuerries.SpecifyDouble("Specify z-scaling", CMD_Development.double_2, false, false, false, false);
                CMD_Development.string_5 = CommandLineQuerries.KeywordYesNo("Include first derivative (slope)", CMD_Development.string_5, false, false);
                if (CMD_Development.string_5 == "Y")
                {
                    CMD_Development.double_3 = CommandLineQuerries.SpecifyDouble("Specify z-scaling for derivative", CMD_Development.double_3, false, false, false, false);
                }
                CMD_Development.string_4 = CommandLineQuerries.SpecifyOutfileType(CMD_Development.string_4);
                CommandLineQuerries.SpecifyFileNameForWrite(ref CMD_Development.string_0, ref CMD_Development.string_1, CMD_Development.string_4);
                bool   reverse  = CMD_Development.string_2 == "Y";
                double startBGL = 0.0;
                double endBGL   = 1.7976931348623157E+308;
                if (CMD_Development.string_3 == "Y")
                {
                    startBGL = CMD_Development.double_0;
                    endBGL   = CMD_Development.double_1;
                }
                List <Point> list   = this.DevelopPolyline(entity.ObjectId, reverse, startBGL, endBGL);
                List <Point> points = new List <Point>();
                if (CMD_Development.string_5 == "Y")
                {
                    points = this.Derivative(list);
                }
                CMD_Development.Result result = new CMD_Development.Result(list, startBGL);
                editor.WriteMessage("\n" + result.ToString());
                Database database = new Database(true, true);
                using (Transaction transaction = database.TransactionManager.StartTransaction())
                {
                    BlockTable        blockTable        = (BlockTable)transaction.GetObject(database.BlockTableId, (OpenMode)1);
                    BlockTableRecord  blockTableRecord  = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                    bool              flag              = false;
                    ObjectId          layerId           = DBManager.CreateLayer("profile", 7, false, ref flag, database);
                    Point3dCollection point3dCollection = Conversions.ToPoint3dCollection(list);
                    Polyline3d        polyline3d        = new Polyline3d(0, point3dCollection, false);
                    point3dCollection.Dispose();
                    polyline3d.LayerId = (layerId);
                    blockTableRecord.AppendEntity(polyline3d);
                    transaction.AddNewlyCreatedDBObject(polyline3d, true);
                    if (CMD_Development.string_5 == "Y")
                    {
                        bool              flag2              = false;
                        ObjectId          layerId2           = DBManager.CreateLayer("slope", 4, false, ref flag2, database);
                        Point3dCollection point3dCollection2 = Conversions.ToPoint3dCollection(points);
                        Polyline3d        polyline3d2        = new Polyline3d(0, point3dCollection2, false);
                        point3dCollection2.Dispose();
                        polyline3d2.LayerId = (layerId2);
                        blockTableRecord.AppendEntity(polyline3d2);
                        transaction.AddNewlyCreatedDBObject(polyline3d2, true);
                    }
                    transaction.Commit();
                    polyline3d.Dispose();
                }
                DBManager.SaveDrawing(database, CMD_Development.string_0, CMD_Development.string_4, (DwgVersion)29);
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine);
            }
        }