Example #1
0
        /// <summary>
        /// Lists all available blocks in the current drawing
        /// </summary>
        /// <returns></returns>
        public static Block[] AvailableBlockDefinitions()
        {
            IBlockHelper helper = HostFactory.Factory.GetBlockHelper();
            if (null == helper)
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "Block.AvailableBlockDefinitions"));

            string[] blockNames = helper.ListAllBlocksInCurrentDocument();
            List<Block> blocks = new List<Block>();
            foreach (var name in blockNames)
            {
                Block block = new Block(name);
                blocks.Add(block);
            }
            return blocks.ToArray();
        }
Example #2
0
 internal BlockInstance(CoordinateSystem contextCoordinateSystem, string blockName, bool persist)
     : base(Block.InsertCore(contextCoordinateSystem, blockName),persist)
 {
     Definition = new Block(blockName);
     ContextCoordinateSystem = contextCoordinateSystem;
 }
Example #3
0
        /// <summary>
        /// Imports all blocks in the outside file to the current drawing
        /// </summary>
        /// <param name="filePath">the file path for the outside file</param>
        /// <returns></returns>
        public static Block[] ImportAll(string filePath)
        {
            string kMethodName = "Block.ImportAll";

            filePath = GeometryExtension.LocateFile(filePath);
            if (!File.Exists(filePath))
                throw new ArgumentException(string.Format(Properties.Resources.FileNotFound, filePath), "filePath");

            IBlockHelper helper = HostFactory.Factory.GetBlockHelper();
            if (null == helper)
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName));

            string[] blockNames = helper.ImportAllBlocksFromFile(filePath);
            List<Block> blocks = new List<Block>();
            foreach (var name in blockNames)
            {
                Block block = new Block(name, filePath);
                blocks.Add(block);
            }
            return blocks.ToArray();
        }