/// <summary>
        /// Draws the arrow.
        /// </summary>
        /// <param name="arrow">The arrow direction.</param>
        /// <param name="blockDirPath">The Design line bloick directory path.</param>
        /// <param name="insertionPoint">The insertion point.</param>
        /// <param name="rotation">The arrwo rotation.</param>
        /// <param name="tr">The active transaction.</param>
        /// <returns>The drew arrow</returns>
        public static ObjectId DrawArrow(this ArrowDirection arrow, Point3d insertionPoint, Double rotation, String blockDirPath, Transaction tr)
        {
            //Se realiza la selección del archivo.
            String pth = Path.Combine(blockDirPath, FOLDER_MISC);

            FileInfo[] files;
            if (Directory.Exists(pth))
            {
                files = new DirectoryInfo(pth).GetFiles();
            }
            else
            {
                files = new FileInfo[0];
            }
            string   arrowName = arrow.GetArrowDirectionName();
            FileInfo arrowFile = files.FirstOrDefault(x => x.Name.ToUpper() == String.Format("{0}.DWG", arrowName).ToUpper());

            if (arrowFile != null && arrowFile.Exists)
            {
                AutoCADBlock     arrowBlock   = new AutoCADBlock(String.Format(SUFFIX_ARROW, arrowName), arrowFile, tr);
                BlockTableRecord currentSpace = (BlockTableRecord)Application.DocumentManager.MdiActiveDocument.Database.CurrentSpaceId.GetObject(OpenMode.ForWrite);
                BlockReference   blkRef       = arrowBlock.CreateReference(insertionPoint, rotation, 1);
                return(blkRef.Draw(currentSpace, tr));
            }
            else
            {
                throw new RivieraException(String.Format(ERR_MISS_ARROW, arrowName, pth));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Inserts this instance block as a BlockReference.
        /// </summary>
        /// <param name="doc">The active document.</param>
        /// <param name="tr">The active transaction.</param>
        /// <param name="insPt">The insertion point.</param>
        /// <param name="angle">The block rotation.</param>
        /// <param name="scale">The block scale.</param>
        /// <returns>The Block Reference</returns>
        public BlockReference Insert(Document doc, Transaction tr, Point3d insPt, Double angle = 0, Double scale = 1)
        {
            BlockTable     blockTable = doc.Database.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;
            AutoCADBlock   instance = null, content;
            BlockReference blockContent;
            Boolean        is2DBlock = !App.Riviera.Is3DEnabled;

            if (!blockTable.Has(this.InstanceBlockName) && this.LoadBlocks(doc, tr, out instance, out content, is2DBlock))
            {
                this.SetContent(is2DBlock, out blockContent, doc, tr);
            }
            else
            {
                this.LoadBlocks(doc, tr, out instance, out content, is2DBlock);
                instance = new AutoCADBlock(this.InstanceBlockName, tr);
            }
            if (instance != null)
            {
                BlockReference   blkRef     = instance.CreateReference(insPt, angle, scale);
                BlockTableRecord modelSpace = tr.GetModelSpace();
                blkRef.Draw(modelSpace, tr);
                AutoCADLayer lay = new AutoCADLayer(LAYER_RIVIERA_GEOMETRY, tr);
                lay.SetStatus(LayerStatus.EnableStatus, tr);
                blkRef.UpgradeOpen();
                blkRef.Layer = lay.Layername;
                return(blkRef);
            }
            else
            {
                throw new RivieraException(String.Format(ERR_LOADING_BLOCK, this.BlockName));
            }
        }
        /// <summary>
        /// Inserts this instance block as a BlockReference.
        /// </summary>
        /// <param name="doc">The active document.</param>
        /// <param name="tr">The active transaction.</param>
        /// <param name="insPt">The insertion point.</param>
        /// <param name="angle">The block rotation.</param>
        /// <param name="scale">The block scale.</param>
        /// <returns>
        /// The Block Reference
        /// </returns>
        /// <exception cref="RivieraException">Si existe un error al insertar el bloque</exception>
        public BlockReference Insert(Document doc, Transaction tr, LBlockType blockDir, Point3d insPt, double angle = 0, double scale = 1)
        {
            BlockTable   blockTable = doc.Database.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;
            AutoCADBlock instance;
            Boolean      is2DBlock    = !App.Riviera.Is3DEnabled;
            String       instanceName = this.GetInstanceName(blockDir);

            if (!blockTable.Has(instanceName))
            {
                instance = this.SetContent(blockDir, is2DBlock, doc, tr);
            }
            else
            {
                Dictionary <LBlockType, AutoCADBlock> blocks2d, blocks3d;
                this.LoadBlocks(doc, tr, out blocks2d, out blocks3d);
                instance = new AutoCADBlock(instanceName, tr);
            }
            //Se realizá la inserción de la instancia
            if (instance != null)
            {
                BlockReference   blkRef     = instance.CreateReference(insPt, angle, scale);
                BlockTableRecord modelSpace = tr.GetModelSpace();
                blkRef.Draw(modelSpace, tr);
                AutoCADLayer lay = new AutoCADLayer(LAYER_RIVIERA_GEOMETRY, tr);
                lay.SetStatus(LayerStatus.EnableStatus, tr);
                blkRef.UpgradeOpen();
                blkRef.Layer = lay.Layername;
                return(blkRef);
            }
            else
            {
                throw new RivieraException(String.Format(ERR_LOADING_BLOCK, this.BlockName));
            }
        }