示例#1
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 DSBlock[] ImportAll(string filePath)
        {
            string kMethodName = "DSBlock.ImportAll";

            filePath = DSGeometryExtension.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 <DSBlock> blocks     = new List <DSBlock>();

            foreach (var name in blockNames)
            {
                DSBlock block = new DSBlock(name, filePath);
                blocks.Add(block);
            }
            return(blocks.ToArray());
        }