static public void RefMgrPallet() // This method can have any name
        {
            // check to see if this command has not been run before
            if (_PalletRefMgr == null)
            {
                // if not, then create our windows - first the paletteset container window
                // we won't generate a Guid for the paletteset as that would then require
                // demand loading
                _PalletRefMgr = new PaletteSet("Reference Manager");
                // next the WPF UserControl
                _formRefMgr = new ArCaPaletteMain();

                // now add the user control to the paletteset
                _PalletRefMgr.AddVisual("Reference Manager Palette", _formRefMgr);
                _PalletRefMgr.Size         = new System.Drawing.Size(345, 300);
                _PalletRefMgr.SizeChanged += new PaletteSetSizeEventHandler(ps_SizeChanged);
                _PalletRefMgr.KeepFocus    = false;

                ArCaRefMgrController.Initialize();
                _formRefMgr.GridMain.DataContext = ArCaRefMgrController.ObjMain;
            }

            // finally, we need to show the paletteset
            // this also serves as a way to redisplay the paletteset if closed
            // by the user
            _PalletRefMgr.Visible = true;
        }
        static public void CmdInset() // This method can have any name
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            PromptStringOptions optName = new PromptStringOptions("\nEnter the name of the block: ");

            optName.AllowSpaces = true;

            if (_sLastBlock == string.Empty)
            {
                optName.UseDefaultValue = true;
                optName.DefaultValue    = _sLastBlock;
            }

            //Loop
            do
            {
                //Esk the user by block name
                PromptResult ProNameRes = ed.GetString(optName);

                if (ProNameRes.Status == PromptStatus.Cancel)
                {
                    break;//Command canceled, go out of loop
                }
                else
                {
                    BlockModel objBlock = ArCaRefMgrController.GetBlockModelByName(ProNameRes.StringResult);
                    if (objBlock != null)
                    {
                        //Block found, insert.
                        InsestBlock(objBlock);
                        //Save the name of inserted block
                        _sLastBlock = ProNameRes.StringResult;
                        //Go out of Loop
                        break;
                    }
                    else
                    {
                        ed.WriteMessage("\nNot foud any block with name \"" + ProNameRes.StringResult + "\".");
                    }
                }
            }while(true);
        }
        //Block Insertor
        static public void InsestBlock(BlockModel objBlockModel)
        {
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            Editor   ed = Application.DocumentManager.MdiActiveDocument.Editor;

            //InsertionState
            BlockInsetions insState = BlockInsetions.Insert;

            //Variables
            Point3d p3dInsetion     = new Point3d();
            Point3d p3dMatrixCorner = new Point3d();


            //Get objId
            ObjectId objId = ArCaRefMgrController.GetBlockId(objBlockModel);
            //Create BlockReference
            BlockReference blockRef = new BlockReference(new Point3d(), objId);
            //Get BlockPropertyModel
            BlockPropModel objBloPro = objBlockModel.LstBlockProp[0];

            //Set properties in BlockRefernce
            blockRef.Rotation     = ArCaUtils.DegreeToRadian(objBloPro.Angle);
            blockRef.ScaleFactors = new Scale3d(objBloPro.SclX, objBloPro.SclY, objBloPro.SclZ);

            //Mirror Settings
            bool bTop  = true;
            bool bLeft = true;

            //Strategy for Preview in PointMonitor
            _PointMonitorStrategy = new PointMonitorStrategy(delegate(object sender, PointMonitorEventArgs e)
            {
                try
                {
                    switch (insState)
                    {
                    case BlockInsetions.Insert:
                        blockRef.Position = e.Context.ComputedPoint;
                        e.Context.DrawContext.Geometry.Draw(blockRef);
                        break;

                    case BlockInsetions.Rotate:
                        blockRef.Rotation = Vector3d.XAxis.GetAngleTo(p3dInsetion.GetVectorTo(e.Context.ComputedPoint), Vector3d.ZAxis);
                        e.Context.DrawContext.Geometry.Draw(blockRef);
                        break;

                    case BlockInsetions.Scale:
                        blockRef.ScaleFactors = new Scale3d(p3dInsetion.DistanceTo(e.Context.ComputedPoint));
                        e.Context.DrawContext.Geometry.Draw(blockRef);
                        break;

                    case BlockInsetions.Mirror:

                        if (e.Context.ComputedPoint.X < p3dInsetion.X && bLeft)
                        {
                            blockRef.ScaleFactors = new Scale3d(-(blockRef.ScaleFactors.X), blockRef.ScaleFactors.Y, blockRef.ScaleFactors.Z);
                            bLeft = false;
                        }
                        else if (e.Context.ComputedPoint.X > p3dInsetion.X && !bLeft)
                        {
                            blockRef.ScaleFactors = new Scale3d(-(blockRef.ScaleFactors.X), blockRef.ScaleFactors.Y, blockRef.ScaleFactors.Z);
                            bLeft = true;
                        }
                        if (e.Context.ComputedPoint.Y < p3dInsetion.Y && bTop)
                        {
                            blockRef.ScaleFactors = new Scale3d(blockRef.ScaleFactors.X, -(blockRef.ScaleFactors.Y), blockRef.ScaleFactors.Z);
                            bTop = false;
                        }
                        else if (e.Context.ComputedPoint.Y > p3dInsetion.Y && !bTop)
                        {
                            blockRef.ScaleFactors = new Scale3d(blockRef.ScaleFactors.X, -(blockRef.ScaleFactors.Y), blockRef.ScaleFactors.Z);
                            bTop = true;
                        }
                        e.Context.DrawContext.Geometry.Draw(blockRef);
                        break;

                    case BlockInsetions.Matrix:
                        //Get pt array
                        Point3dCollection pt3DColl = Utils.ArCaUtils.GetPtArray(p3dInsetion, e.Context.ComputedPoint, objBloPro.MatrixHeight, objBloPro.MatrixWidth);
                        double iLimitator          = objBloPro.MatrixMaxQuant;
                        foreach (Point3d pt3D in pt3DColl)
                        {
                            //Insert Block
                            blockRef.Position = pt3D;
                            e.Context.DrawContext.Geometry.Draw(blockRef);
                            //Limitator to evoid chash in machine
                            iLimitator--;
                            if (iLimitator < 1)
                            {
                                break;
                            }
                        }
                        break;
                    }
                }
                catch (System.Exception ex)
                {
                }
            });

            //add pointMonitor
            ed.PointMonitor += new PointMonitorEventHandler(PointMonitor);

            //Looping for Insertion in Loop
            do
            {
                //***Insertion point***
                insState = BlockInsetions.Insert;

                PromptPointOptions opcPt = new PromptPointOptions("\nClick on the insertion point: ");
                opcPt.AllowNone = false;
                PromptPointResult ProPtRes = ed.GetPoint(opcPt);

                if (ProPtRes.Status != PromptStatus.OK)
                {
                    //Command Canceled
                    break;
                }

                p3dInsetion     = ProPtRes.Value;
                p3dMatrixCorner = ProPtRes.Value;

                //***ROTATE***
                if (objBloPro.Rotate)
                {
                    insState = BlockInsetions.Rotate;

                    PromptAngleOptions opcAng = new PromptAngleOptions("\nDefine the rotation angle: ");
                    opcAng.AllowNone    = true;
                    opcAng.UseBasePoint = true;
                    opcAng.BasePoint    = p3dInsetion;
                    opcAng.DefaultValue = 0;
                    PromptDoubleResult ProAngRes = ed.GetAngle(opcAng);

                    if (ProAngRes.Status == PromptStatus.Cancel)
                    {
                        //Command Canceled, exit to "Loopin"
                        break;
                    }
                }

                //***SCALE***
                if (objBloPro.Scale)
                {
                    insState = BlockInsetions.Scale;

                    PromptDistanceOptions opcScl = new PromptDistanceOptions("\nDefine the scale factor: ");
                    opcScl.AllowNone    = true;
                    opcScl.UseBasePoint = true;
                    opcScl.BasePoint    = p3dInsetion;
                    opcScl.DefaultValue = 1;
                    PromptDoubleResult ProSclRes = ed.GetDistance(opcScl);

                    if (ProSclRes.Status == PromptStatus.Cancel)
                    {
                        //Command Canceled, exit to "Loopin"
                        break;
                    }
                }

                //***MIRROR***
                if (objBloPro.Mirror)
                {
                    insState = BlockInsetions.Mirror;

                    PromptPointOptions opcMatCor = new PromptPointOptions("\nClick on the point that define the mirror direction: ");
                    opcMatCor.AllowNone    = false;
                    opcMatCor.UseBasePoint = true;
                    opcMatCor.BasePoint    = p3dInsetion;
                    PromptPointResult ProMatCorRes = ed.GetPoint(opcMatCor);

                    if (ProMatCorRes.Status != PromptStatus.OK)
                    {
                        //Command Canceled, exit to "Loopin"
                        break;
                    }
                }

                //***MATRIX***
                if (objBloPro.Matrix)
                {
                    insState = BlockInsetions.Matrix;

                    PromptPointOptions opcMatCor = new PromptPointOptions("\nClick on the corner point of the matrix: ");
                    opcMatCor.AllowNone = false;
                    PromptPointResult ProMatCorRes = ed.GetPoint(opcMatCor);

                    if (ProMatCorRes.Status != PromptStatus.OK)
                    {
                        //Command Canceled, exit to "Loopin"
                        break;
                    }

                    p3dMatrixCorner = ProMatCorRes.Value;
                }

                //***Insertion of Block***
                //Get pt array
                Point3dCollection pt3DColl   = Utils.ArCaUtils.GetPtArray(p3dInsetion, p3dMatrixCorner, objBloPro.MatrixHeight, objBloPro.MatrixWidth);
                double            iLimitator = objBloPro.MatrixMaxQuant;
                foreach (Point3d pt3D in pt3DColl)
                {
                    //Set Position
                    blockRef.Position = pt3D;
                    //We need clone the block reference to obtain a block wiht other objectID in each iteration
                    BlockReference blockRefClone = blockRef.Clone() as BlockReference;
                    //Insert Block
                    Utils.ArCaUtils.InserBlock(db, objBloPro.Explode, blockRefClone);
                    //Limitator to evoid chash in machine
                    iLimitator--;
                    if (iLimitator < 1)
                    {
                        break;
                    }
                }
            } while (objBloPro.Loop);

            //remove pointMonitor
            ed.PointMonitor -= new PointMonitorEventHandler(PointMonitor);
        }