Esempio n. 1
0
        /// <summary>
        /// Attaches the specified Xref to the current space in the current drawing.
        /// </summary>
        /// <param name="path">Path to the drawing file to attach as an Xref.</param>
        /// <param name="pos">Position of Xref in WCS coordinates.</param>
        /// <param name="name">Optional name for the Xref.</param>
        /// <returns>Whether the attach operation succeeded.</returns>
        public static bool XrefAttachAndInsert(this Database db, string path, Point3d pos, string name = null, bool overlay = false)
        {
            var ret = false;

            if (!File.Exists(path))
            {
                return(ret);
            }
            if (String.IsNullOrEmpty(name))
            {
                name = Path.GetFileNameWithoutExtension(path);
            }
            // We'll collect any xref definitions that need reloading after our
            // transaction (there should be at most one)
            var xIds = new ObjectIdCollection();

            try
            {
                using (var tr = db.TransactionManager.StartTransaction())
                {
                    // Attach or overlay the Xref - add it to the database's block table
                    var xId =
                        overlay ? db.OverlayXref(path, name) : db.AttachXref(path, name);
                    if (xId.IsValid)
                    {
                        // Open the newly created block, so we can get its units
                        var xbtr = (BlockTableRecord)tr.GetObject(xId, OpenMode.ForRead);
                        // Get the path of the current drawing
                        var loc = Path.GetDirectoryName(db.Filename);
                        if (xbtr.ChangePathToRelative(loc))
                        {
                            xIds.Add(xId);
                        }
                        // Determine the unit conversion between the xref and the target
                        // database
                        var sf = UnitsConverter.GetConversionFactor(xbtr.Units, db.Insunits);
                        // Create the block reference and scale it accordingly
                        var br = new BlockReference(pos, xId);
                        br.ScaleFactors = new Scale3d(sf);
                        // Add the block reference to the current space and the transaction
                        var btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                        btr.AppendEntity(br);
                        tr.AddNewlyCreatedDBObject(br, true);
                        ret = true;
                    }
                    tr.Commit();
                }
                // If we modified our xref's path, let's reload it
                if (xIds.Count > 0)
                {
                    //db.ReloadXrefs(xIds);
                    System.Windows.Forms.MessageBox.Show("You need reload Xrefs!");
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception)
            { }
            return(ret);
        }
Esempio n. 2
0
        void tableRegDescr_CellPropertyChanged(object sender, XPTable.Events.CellEventArgs e)
        {
            // MessageBox.Show( e.CellPos.Column + "\n" + e.CellPos.Row + "\n" + e.Cell.Text + "\n" +  tableRegDescr.TableModel.Rows[e.CellPos.Row].Cells[0].Text + "\n" + e.OldValue);

            if (e.Column == 1)
            {
                if (tableRegDescr.TableModel.Rows[e.CellPos.Row].Cells[0].Text == " Density")
                {
                    RMS.Density = Convert.ToDouble(tableRegDescr.TableModel.Rows[15].Cells[1].Data);
                    RMS.G       = RMS.Density * RMS.LinearVolume;
                    tableRegDescr.TableModel.Rows[16].Cells[1].Data = RMS.G;
                    tableRegDescr.TableModel.Rows[17].Cells[1].Data = RMS.G;
                    tableRegDescr.TableModel.Rows[18].Cells[1].Data = RMS.G * 9.80665;
                }

                return;
            }

            UnitsValue UnitToConvertTo = UnitsValue.Millimeters;

            foreach (UnitsValue aUnit in Enum.GetValues(typeof(UnitsValue)))
            {
                if (aUnit.ToString() == e.Cell.Text)
                {
                    UnitToConvertTo = aUnit;
                }
            }

            string     checkStr        = tableRegDescr.TableModel.Rows[e.CellPos.Row].Cells[0].Text;
            UnitsValue scaleUnitsValue = UnitsValue.Millimeters;
            string     sysUnits        = (Application.GetSystemVariable("INSUNITS")).ToString();

            switch (sysUnits)
            {
            case "1":
                scaleUnitsValue = UnitsValue.Inches;
                break;

            case "2":
                scaleUnitsValue = UnitsValue.Feet;
                break;

            case "4":
                scaleUnitsValue = UnitsValue.Millimeters;
                break;

            case "5":
                scaleUnitsValue = UnitsValue.Centimeters;
                break;

            case "6":
                scaleUnitsValue = UnitsValue.Meters;
                break;

            case "14":
                scaleUnitsValue = UnitsValue.Decimeters;
                break;

            default:
                MessageBox.Show("\nUnits to scale inserted content: UNRECOGNIZED ?!", "units E R R O R");
                break;
            }
            switch (checkStr.Remove(0, 1) /*tableRegDescr.TableModel.Rows[e.CellPos.Row].Cells[0].Text*/)
            {
            case "Area":
                RMS.AreaUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[0].Cells[1].Data = RMS.Area *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.AreaUnit), 2);
                break;

            case "Iy":
                RMS.IyUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[1].Cells[1].Data = RMS.Iy *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.IyUnit), 4);
                break;

            case "Wy_Upper":
                RMS.WyUpperUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[2].Cells[1].Data = RMS.WyUpper *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.WyUpperUnit), 3);
                break;

            case "Wy_Lower":
                RMS.WyLowerUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[3].Cells[1].Data = RMS.WyLower *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.WyLowerUnit), 3);
                break;

            case "D_Upper":
                RMS.DUpperUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[4].Cells[1].Data = RMS.DUpper *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.DUpperUnit), 1);
                break;

            case "D_Lower":
                RMS.DLowerUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[5].Cells[1].Data = RMS.DLower *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.DLowerUnit), 1);
                break;

            case "Iyy":
                RMS.IyyUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[6].Cells[1].Data = RMS.Iyy *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.IyyUnit), 1);
                break;

            case "Iz":
                RMS.IzUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[7].Cells[1].Data = RMS.Iz *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.IzUnit), 4);
                break;

            case "Wz_Right":
                RMS.WzRightUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[8].Cells[1].Data = RMS.WzRight *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.WzRightUnit), 3);
                break;

            case "Wz_Left":
                RMS.WzLeftUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[9].Cells[1].Data = RMS.WzLeft *
                                                                 Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.WzLeftUnit), 3);
                break;

            case "D_Right":
                RMS.DRightUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[10].Cells[1].Data = RMS.DRight *
                                                                  Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.DRightUnit), 1);
                break;

            case "D_Left":
                RMS.DLeftUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[11].Cells[1].Data = RMS.DLeft *
                                                                  Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.DLeftUnit), 1);
                break;

            case "Izz":
                RMS.IzzUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[12].Cells[1].Data = RMS.Izz *
                                                                  Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.IzzUnit), 1);
                break;

            case "Imin":
                RMS.IminUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[13].Cells[1].Data = RMS.Imin *
                                                                  Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.IminUnit), 4);
                break;

            case "Imax":
                RMS.ImaxUnit = UnitToConvertTo;
                tableRegDescr.TableModel.Rows[14].Cells[1].Data = RMS.Imax *
                                                                  Math.Pow(
                    UnitsConverter.GetConversionFactor(
                        scaleUnitsValue, RMS.ImaxUnit), 4);
                break;
                // case "Density":
                // RMS.DensityUnit = UnitToConvertTo;
                //  break;
                //   case "G":
                //RMS.GUnit = UnitToConvertTo;
                //     break;
                //   case "LinearVolume":
                //     RMS.LinearVolumeUnit = UnitToConvertTo;
                //    break;
            }

            // RegionDescription.DrawText( ref RMS );
        }
Esempio n. 3
0
        public static void doclipboxnw(string command)
        {
            Helper.Initialize();

            try

            {
                PromptSelectionResult selectionRes = Helper.oEditor.SelectImplied();

                // If there's no pickfirst set available...

                if (selectionRes.Status == PromptStatus.Error)

                {
                    // ... ask the user to select entities
                    if (!command.Equals("ClipBoxNwReset"))
                    {
                        PromptSelectionOptions selectionOpts = new PromptSelectionOptions();

                        selectionOpts.SingleOnly       = true;
                        selectionOpts.MessageForAdding = "\n(Unload NWD first, press esc now if still loaded) Select object to define area of interest..";

                        if (command.Equals("ClipBoxNwWriteBatchOnly"))
                        {
                            selectionOpts.SingleOnly       = false;
                            selectionOpts.MessageForAdding = "\nSelect all objects defining areas and then press enter..";
                        }
                        selectionRes = Helper.oEditor.GetSelection(selectionOpts);
                    }
                }

                else

                {
                    // If there was a pickfirst set, clear it

                    Helper.oEditor.SetImpliedSelection(new ObjectId[0]);
                }

                // If the user has not cancellHelper.oEditor...

                if (selectionRes.Status == PromptStatus.OK || command.Equals("ClipBoxNwReset"))

                {
                    // ... take the selected objects one by one



                    using (Transaction tr = Helper.ActiveDocument.Database.TransactionManager.StartTransaction())
                    {
                        string     documentspath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                        string     batpath       = documentspath + "\\" + "clipboxnw.bat";
                        string     commandline   = "";
                        Point3d    min           = new Point3d(0, 0, 0);
                        Point3d    max           = new Point3d(0, 0, 0);
                        ObjectId[] objIds        = new ObjectId[] { };

                        if (!command.Equals("ClipBoxNwReset"))
                        {
                            objIds = selectionRes.Value.GetObjectIds();
                        }
                        else
                        {
                            objIds = new ObjectId[] { new ObjectId() }
                        };

                        int counter = 0;

                        foreach (ObjectId objId in objIds)
                        {
                            string suffix = "";
                            if (counter > 0)
                            {
                                suffix = "_" + counter.ToString();
                            }
                            ++counter;

                            if (!command.Equals("ClipBoxNwReset"))
                            {
                                Entity ent = (Entity)tr.GetObject(objId, OpenMode.ForRead);

                                min = ent.Bounds.Value.MinPoint;
                                max = ent.Bounds.Value.MaxPoint;

                                ent.Dispose();
                            }

                            double conversionfactor = UnitsConverter.GetConversionFactor(Helper.oDatabase.Insunits, UnitsValue.Meters);

                            commandline += "\"D:\\Program Files\\Autodesk\\Navisworks Manage 2020\\Roamer.exe\" -NoGui -OpenFile";
                            commandline += " \"" + documentspath + "\\" + "CoordinationModel.nwd\"";
                            commandline += " -ExecuteAddInPlugin \"ClipBox.AClipBox.ADSK\"";
                            commandline += " \"" + documentspath + "\\" + "CoordinationModel" + suffix + ".nwd\"";
                            commandline += " " + Math.Round(min.X * conversionfactor, 3).ToString().Replace("-", "neg");
                            commandline += " " + Math.Round(min.Y * conversionfactor, 3).ToString().Replace("-", "neg");
                            commandline += " " + Math.Round(min.Z * conversionfactor, 3).ToString().Replace("-", "neg");
                            commandline += " " + Math.Round(max.X * conversionfactor, 3).ToString().Replace("-", "neg");
                            commandline += " " + Math.Round(max.Y * conversionfactor, 3).ToString().Replace("-", "neg");
                            commandline += " " + Math.Round(max.Z * conversionfactor, 3).ToString().Replace("-", "neg");
                            commandline += "\r\n";
                        }

                        File.WriteAllText(batpath, commandline);


                        if (!command.Equals("ClipBoxNwWriteBatchOnly"))
                        {
                            Process ExternalProcess = new Process();
                            ExternalProcess.StartInfo.FileName    = batpath;
                            ExternalProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                            ExternalProcess.Start();
                            ExternalProcess.WaitForExit();
                        }

                        /*var btr = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Helper.oDatabase), OpenMode.ForRead);
                         *
                         * foreach (ObjectId id in btr)
                         * {
                         *  //Entity ente = (Entity)tr.GetObject(id, OpenMode.ForRead);
                         *  DBObject ente = (DBObject)tr.GetObject(id, OpenMode.ForRead);
                         *  Helper.oEditor.WriteMessage("\nmessage: " + ente.GetType().ToString());
                         *  if (ente.GetType().ToString().EndsWith("ImpEntity"))
                         *  {
                         *      ((AcBIMUnderlayDbx)ente).Unload(false);
                         *      //ShowType(id);
                         *  }
                         *
                         * }*/
                        string logtext     = "";
                        string logfilepath = documentspath + "\\" + "CoordinationModel.nwd.txt";
                        if (File.Exists(logfilepath))
                        {
                            logtext = File.ReadAllText(logfilepath);
                        }

                        if (command.Equals("ClipBoxNwWriteBatchOnly"))
                        {
                            Helper.oEditor.WriteMessage("\nclipboxnw.bat was created in the documents folder. Edit clipboxnw.bat for further use.");
                        }
                        else
                        {
                            if (!logtext.Equals(""))
                            {
                                Helper.oEditor.WriteMessage("\n" + logtext);
                            }
                            else
                            {
                                Helper.oEditor.WriteMessage("\nCoordinationModel.nwd was updated. Now reload CoordinationModel.nwd");
                            }
                        }
                        tr.Commit();
                    }
                }
            }

            catch (Autodesk.AutoCAD.Runtime.Exception ex)

            {
                Helper.oEditor.WriteMessage(ex.Message);
            }

            Helper.Terminate();
        }
Esempio n. 4
0
        /// <summary>
        /// Generate Viewpoint
        /// </summary>
        /// <param name="elemCheck"></param>
        /// <returns></returns>
        public VisualizationInfo generateViewpoint(int elemCheck)
        {
            try
            {
                // get current view
                Database        acCurDb     = doc.Database;
                ViewTableRecord currentView = doc.Editor.GetCurrentView();
                double          unitFactor  = UnitsConverter.GetConversionFactor(acCurDb.Insunits, UnitsValue.Meters);

                // camera direction
                Vector3d direction = currentView.ViewDirection.Negate();

                // camera scale
                double h = currentView.Height * unitFactor;
                double w = currentView.Width * unitFactor;

                // transform from DCS to WCS
                Matrix3d matDCS2WCS;
                matDCS2WCS = Matrix3d.PlaneToWorld(currentView.ViewDirection);
                matDCS2WCS = Matrix3d.Displacement(currentView.Target - Point3d.Origin) * matDCS2WCS;
                matDCS2WCS = Matrix3d.Rotation(-currentView.ViewTwist,
                                               currentView.ViewDirection,
                                               currentView.Target) * matDCS2WCS;

                // camera location
                Point3d centerPointDCS = new Point3d(currentView.CenterPoint.X, currentView.CenterPoint.Y, 0.0);
                Point3d centerWCS      = centerPointDCS.TransformBy(matDCS2WCS);
                Point3d cameraLocation = centerWCS.Subtract(direction) * unitFactor;

                // camera up vector
                Vector3d upVector = new Vector3d(-Math.Sin(currentView.ViewTwist), Math.Cos(currentView.ViewTwist), 0.0).TransformBy(matDCS2WCS).GetNormal();

                // set up BCF viewpoint
                VisualizationInfo v = new VisualizationInfo();

                if (currentView.PerspectiveEnabled)
                {
                    v.PerspectiveCamera = new PerspectiveCamera();
                    v.PerspectiveCamera.CameraViewPoint.X = cameraLocation.X;
                    v.PerspectiveCamera.CameraViewPoint.Y = cameraLocation.Y;
                    v.PerspectiveCamera.CameraViewPoint.Z = cameraLocation.Z;
                    v.PerspectiveCamera.CameraUpVector.X  = upVector.X;
                    v.PerspectiveCamera.CameraUpVector.Y  = upVector.Y;
                    v.PerspectiveCamera.CameraUpVector.Z  = upVector.Z;
                    v.PerspectiveCamera.CameraDirection.X = direction.GetNormal().X;
                    v.PerspectiveCamera.CameraDirection.Y = direction.GetNormal().Y;
                    v.PerspectiveCamera.CameraDirection.Z = direction.GetNormal().Z;
                    v.PerspectiveCamera.FieldOfView       = 40;
                }
                else
                {
                    v.OrthogonalCamera = new OrthogonalCamera();
                    v.OrthogonalCamera.CameraViewPoint.X = cameraLocation.X;
                    v.OrthogonalCamera.CameraViewPoint.Y = cameraLocation.Y;
                    v.OrthogonalCamera.CameraViewPoint.Z = cameraLocation.Z;
                    v.OrthogonalCamera.CameraUpVector.X  = upVector.X;
                    v.OrthogonalCamera.CameraUpVector.Y  = upVector.Y;
                    v.OrthogonalCamera.CameraUpVector.Z  = upVector.Z;
                    v.OrthogonalCamera.CameraDirection.X = direction.GetNormal().X;
                    v.OrthogonalCamera.CameraDirection.Y = direction.GetNormal().Y;
                    v.OrthogonalCamera.CameraDirection.Z = direction.GetNormal().Z;
                    v.OrthogonalCamera.ViewToWorldScale  = h;
                }

                return(v);
            }
            catch (System.Exception ex1)
            {
                MessageBox.Show("exception: " + ex1, "Error!");
            }
            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// Open a 3D View
        /// </summary>
        /// <param name="v"></param>
        private void doOpen3DView(VisualizationInfo v)
        {
            try
            {
                if (doc.Editor.GetCurrentView().IsPaperspaceView)
                {
                    MessageBox.Show("This operation is not allowed in paper space.\nPlease go to model space and retry.",
                                    "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                // Get the current database
                Database acCurDb    = doc.Database;
                double   unitFactor = UnitsConverter.GetConversionFactor(UnitsValue.Meters, acCurDb.Insunits);

                Point3d  wcsCenter;
                Vector3d viewDirection, upVector;
                double   zoomValue;

                // IS ORTHOGONAL
                if (v.OrthogonalCamera != null)
                {
                    if (v.OrthogonalCamera.CameraViewPoint == null || v.OrthogonalCamera.CameraUpVector == null || v.OrthogonalCamera.CameraDirection == null)
                    {
                        return;
                    }

                    wcsCenter     = new Point3d(v.OrthogonalCamera.CameraViewPoint.X, v.OrthogonalCamera.CameraViewPoint.Y, v.OrthogonalCamera.CameraViewPoint.Z);
                    viewDirection = new Vector3d(v.OrthogonalCamera.CameraDirection.X, v.OrthogonalCamera.CameraDirection.Y, v.OrthogonalCamera.CameraDirection.Z);
                    upVector      = new Vector3d(v.OrthogonalCamera.CameraUpVector.X, v.OrthogonalCamera.CameraUpVector.Y, v.OrthogonalCamera.CameraUpVector.Z);
                    zoomValue     = v.OrthogonalCamera.ViewToWorldScale;
                }
                else if (v.PerspectiveCamera != null)
                {
                    if (v.PerspectiveCamera.CameraViewPoint == null || v.PerspectiveCamera.CameraUpVector == null || v.PerspectiveCamera.CameraDirection == null)
                    {
                        return;
                    }

                    wcsCenter     = new Point3d(v.PerspectiveCamera.CameraViewPoint.X, v.PerspectiveCamera.CameraViewPoint.Y, v.PerspectiveCamera.CameraViewPoint.Z);
                    viewDirection = new Vector3d(v.PerspectiveCamera.CameraDirection.X, v.PerspectiveCamera.CameraDirection.Y, v.PerspectiveCamera.CameraDirection.Z);
                    upVector      = new Vector3d(v.PerspectiveCamera.CameraUpVector.X, v.PerspectiveCamera.CameraUpVector.Y, v.PerspectiveCamera.CameraUpVector.Z);
                    zoomValue     = v.PerspectiveCamera.FieldOfView;
                }
                else
                {
                    MessageBox.Show("No camera information was found within this viewpoint.",
                                    "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                // Start a transaction
                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    // Get the current view
                    using (ViewTableRecord currentView = doc.Editor.GetCurrentView())
                    {
                        // Calculate the ratio between the width and height of the current view
                        double dViewRatio;
                        dViewRatio = (currentView.Width / currentView.Height);

                        // set target
                        wcsCenter          = wcsCenter * unitFactor;
                        currentView.Target = wcsCenter;

                        // set direction
                        currentView.ViewDirection = viewDirection.GetNormal().Negate();

                        // Set scale
                        currentView.Height = zoomValue * unitFactor;
                        currentView.Width  = zoomValue * dViewRatio * unitFactor;

                        Matrix3d matWCS2DCS;
                        matWCS2DCS = Matrix3d.PlaneToWorld(currentView.ViewDirection);
                        matWCS2DCS = Matrix3d.Displacement(currentView.Target - Point3d.Origin) * matWCS2DCS;
                        matWCS2DCS = Matrix3d.Rotation(-currentView.ViewTwist,
                                                       currentView.ViewDirection,
                                                       currentView.Target) * matWCS2DCS;
                        matWCS2DCS = matWCS2DCS.Inverse();

                        // set up vector
                        currentView.ViewTwist = Math.Asin(-upVector.GetNormal().TransformBy(matWCS2DCS).X);

                        // Set the center of the view
                        Point3d dcsCenter = wcsCenter.TransformBy(matWCS2DCS);
                        currentView.CenterPoint = new Point2d(dcsCenter.X, dcsCenter.Y);

                        // Set the current view
                        doc.Editor.SetCurrentView(currentView);
                    }

                    // Commit the changes
                    acTrans.Commit();
                }
            }
            catch (System.Exception ex1)
            {
                MessageBox.Show("exception: " + ex1, "Error!");
            }
        }
Esempio n. 6
0
        public static void DrawText(ref RegionMassProperties aRms, string dU, string mU, Database db)
        {
            #region scale

            var scale           = "mm";
            var scaleUnitsValue = UnitsValue.Millimeters;
            var sysUnits        =
                Application.GetSystemVariable("INSUNITS").ToString();
            switch (sysUnits)
            {
            case "1":
                scale           = "inch";
                scaleUnitsValue = UnitsValue.Inches;
                break;

            case "2":
                scale           = "feet";
                scaleUnitsValue = UnitsValue.Feet;
                break;

            case "4":
                scale           = "mm";
                scaleUnitsValue = UnitsValue.Millimeters;
                break;

            case "5":
                scale           = "cm";
                scaleUnitsValue = UnitsValue.Centimeters;
                break;

            case "6":
                scale           = "m";
                scaleUnitsValue = UnitsValue.Meters;
                break;

            case "14":
                scale           = "dm";
                scaleUnitsValue = UnitsValue.Decimeters;
                break;

            default:
                MessageBox.Show("\nUnits to scale inserted content: UNRECOGNIZED ?!", "units E R R O R");
                break;
            }

            var format       = "f5";
            var mTextMessage = "";

            #endregion

            mTextMessage += AssemblyText(
                "Area",
                aRms.Area * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.AreaUnit), 2),
                aRms.AreaUnit,
                "2",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Iy",
                aRms.Iy * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.IyUnit), 4),
                aRms.IyUnit,
                "4",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Wy_Upper",
                aRms.WyUpper * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.WyUpperUnit), 3),
                aRms.WyUpperUnit,
                "3",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Wy_Lower",
                aRms.WyLower * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.WyLowerUnit), 3),
                aRms.WyLowerUnit,
                "3",
                scale,
                format);
            mTextMessage += AssemblyText(
                "D_Upper",
                aRms.DUpper * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.DUpperUnit), 1),
                aRms.DUpperUnit,
                "",
                scale,
                format);
            mTextMessage += AssemblyText(
                "D_Lower",
                aRms.DLower * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.DLowerUnit), 1),
                aRms.DLowerUnit,
                "",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Iyy",
                aRms.Iyy * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.IyyUnit), 1),
                aRms.IyyUnit,
                "",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Iz",
                aRms.Iz * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.IzUnit), 4),
                aRms.IzUnit,
                "4",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Wz_Right",
                aRms.WzRight * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.WzRightUnit), 3),
                aRms.WzRightUnit,
                "3",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Wz_Left",
                aRms.WzLeft * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.WzLeftUnit), 3),
                aRms.WzLeftUnit,
                "3",
                scale,
                format);
            mTextMessage += AssemblyText(
                "D_Right",
                aRms.DRight * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.DRightUnit), 1),
                aRms.DRightUnit,
                "",
                scale,
                format);
            mTextMessage += AssemblyText(
                "D_Left",
                aRms.DLeft * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.DLeftUnit), 1),
                aRms.DLeftUnit,
                "",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Izz",
                aRms.Izz * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.IzzUnit), 1),
                aRms.IzzUnit,
                "",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Imin",
                aRms.Imin * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.IminUnit), 4),
                aRms.IminUnit,
                "4",
                scale,
                format);
            mTextMessage += AssemblyText(
                "Imax",
                aRms.Imax * Math.Pow(UnitsConverter.GetConversionFactor(scaleUnitsValue, aRms.ImaxUnit), 4),
                aRms.ImaxUnit,
                "4",
                scale,
                format);

            // Density
            var density = aRms.Density * UnitsConverter.GetConversionFactor(UnitsValue.Millimeters, aRms.DensityUnit);
            mTextMessage += "{\\A0Density:\\~" + density.ToString(scale != "m" ? format : "") + "\\~" + dU +
                            "\\S3;}\\P\n";

            // weight G
            var g = aRms.G * UnitsConverter.GetConversionFactor(UnitsValue.Millimeters, aRms.GUnit);
            mTextMessage += "{\\A0G:\\~" + g.ToString(scale != "m" ? format : "") + "\\~" + mU + "}\\P\n";
            Ed.WriteMessage(mTextMessage);

            // draw message
            using (var tr = db.TransactionManager.StartTransaction())
            {
                var bt  = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                var btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                if (!_textId.IsNull && !_textId.IsErased)
                {
                    var regoinTextEnt = (Entity)tr.GetObject(_textId, OpenMode.ForWrite);
                    regoinTextEnt.Erase(true);
                }

                var regionText = new MText();
                regionText.SetDatabaseDefaults();
                regionText.Location = aRms.TextInsertionPoint;
                regionText.Width    = 1000;
                regionText.Height   = 1.2;
                regionText.Contents = mTextMessage + "\n";
                btr.AppendEntity(regionText);
                _textId = regionText.ObjectId;
                tr.AddNewlyCreatedDBObject(regionText, true);
                tr.Commit();
            }

            CommandLineHelper.Command("_REGEN");
        }