コード例 #1
0
        /// <summary>
        /// Loads the blocks.
        /// </summary>
        /// <param name="doc">The active document.</param>
        /// <param name="tr">The active transaction.</param>
        /// <param name="instance">The instance block</param>
        /// <param name="content">The block content</param>
        /// <param name="is2DBlock">if set to <c>true</c> [is a 2D block] otherwise a 3D block.</param>
        /// <returns></returns>
        public Boolean LoadBlocks(Document doc, Transaction tr, out AutoCADBlock instance, out AutoCADBlock content, Boolean is2DBlock = true)
        {
            BlockTable blockTable = (BlockTable)doc.Database.BlockTableId.GetObject(OpenMode.ForRead);

            instance = null;
            content  = null;
            AutoCADBlock block2d, block3d;

            try
            {
                //Esta línea prueba de manerá local la carga de un bloque
                //this.Block2DName._LoadBlock(this.GetBlockFilePath().FullName, tr);
                instance = new AutoCADBlock(this.InstanceBlockName, tr);
                block2d  = new AutoCADBlock(this.Block2DName, this.GetBlockFilePath(), tr);
                block3d  = new AutoCADBlock(this.Block3DName, this.GetBlockFilePath(false), tr);
                content  = is2DBlock ? block2d : block3d;
            }
            catch (Exception exc)
            {
                string msg = String.Format(ERR_LOADING_BLOCK, this.BlockName);
                msg = NamelessUtils.FormatExceptionMessage(exc, msg);
                App.Riviera.Log.AppendEntry(msg, Protocol.Error, "LoadBlocks", "RivieraBlock");
                throw exc.CreateNamelessException <RivieraException>(msg);
            }
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Loads the blocks.
        /// </summary>
        /// <param name="doc">The active document.</param>
        /// <param name="tr">The active transaction.</param>
        /// <param name="instance">The instance block</param>
        /// <param name="content">The block content</param>
        /// <param name="is2DBlock">if set to <c>true</c> [is a 2D block] otherwise a 3D block.</param>
        /// <returns></returns>
        public bool LoadBlocks(Document doc, Transaction tr, out Dictionary <LBlockType, AutoCADBlock> blocks2D, out Dictionary <LBlockType, AutoCADBlock> blocks3D)
        {
            AutoCADBlock block2d, block3d, varBlock2d, varBlock3d;

            blocks2D = new Dictionary <LBlockType, AutoCADBlock>();
            blocks3D = new Dictionary <LBlockType, AutoCADBlock>();
            string blockName    = MinSize > MaxSize ? this.VariantBlockName : this.BlockName,
                   varBlockName = MinSize > MaxSize ? this.BlockName : this.VariantBlockName;

            try
            {
                block2d = new AutoCADBlock(String.Format(Block2DName, blockName), this.GetBlockFilePath(blockName), tr);
                block3d = new AutoCADBlock(String.Format(Block3DName, blockName), this.GetBlockFilePath(blockName, false), tr);
                if (this.MinSize != this.MaxSize)
                {
                    varBlock2d = new AutoCADBlock(String.Format(SUFFIX_BLOCK2D, varBlockName), this.GetBlockFilePath(varBlockName), tr);
                    varBlock3d = new AutoCADBlock(String.Format(SUFFIX_BLOCK3D, varBlockName), this.GetBlockFilePath(varBlockName, false), tr);
                    //Registros 2D
                    blocks2D.Add(LBlockType.LEFT_START_MIN_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_CONT, blockName, "2D", BLOCK_DIR_LFT), tr));
                    blocks2D.Add(LBlockType.RIGHT_START_MIN_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_CONT, blockName, "2D", BLOCK_DIR_RGT), tr));
                    blocks2D.Add(LBlockType.LEFT_START_MAX_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_VAR_CONT, varBlockName, "2D", BLOCK_DIR_LFT), tr));
                    blocks2D.Add(LBlockType.RIGHT_START_MAX_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_VAR_CONT, varBlockName, "2D", BLOCK_DIR_RGT), tr));
                    //Registros 3D
                    blocks3D.Add(LBlockType.LEFT_START_MIN_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_CONT, blockName, "3D", BLOCK_DIR_LFT), tr));
                    blocks3D.Add(LBlockType.RIGHT_START_MIN_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_CONT, blockName, "3D", BLOCK_DIR_RGT), tr));
                    blocks3D.Add(LBlockType.LEFT_START_MAX_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_VAR_CONT, varBlockName, "3D", BLOCK_DIR_LFT), tr));
                    blocks3D.Add(LBlockType.RIGHT_START_MAX_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_VAR_CONT, varBlockName, "3D", BLOCK_DIR_RGT), tr));
                    this.InitContent(tr, blocks2D, blocks3D, block2d, block3d, varBlock2d, varBlock3d);
                }
                else
                {
                    //Registros 2D
                    blocks2D.Add(LBlockType.LEFT_SAME_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_CONT, blockName, "2D", BLOCK_DIR_LFT), tr));
                    blocks2D.Add(LBlockType.RIGHT_SAME_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_CONT, blockName, "2D", BLOCK_DIR_RGT), tr));
                    //Registros 3D
                    blocks3D.Add(LBlockType.LEFT_SAME_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_CONT, blockName, "3D", BLOCK_DIR_LFT), tr));
                    blocks3D.Add(LBlockType.RIGHT_SAME_SIZE, new AutoCADBlock(String.Format(PREFIX_BLOCK_CONT, blockName, "3D", BLOCK_DIR_RGT), tr));
                    this.InitContent(tr, blocks2D, blocks3D, block2d, block3d);
                }
            }
            catch (Exception exc)
            {
                string msg = String.Format(ERR_LOADING_BLOCK, blockName);
                msg = NamelessUtils.FormatExceptionMessage(exc, msg);
                App.Riviera.Log.AppendEntry(msg, Protocol.Error, "LoadBlocks", "RivieraLBlock");
                return(false);
            }
            return(true);
        }