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

            string[] blockNames = helper.ListAllBlocksInCurrentDocument();
            List<DSBlock> blocks = new List<DSBlock>();
            foreach (var name in blockNames)
            {
                DSBlock block = new DSBlock(name);
                blocks.Add(block);
            }
            return blocks.ToArray();
        }
Example #3
0
        /// <summary>
        /// Lists all available blocks in the current drawing
        /// </summary>
        /// <returns></returns>
        public static DSBlock[] AvailableBlockDefinitions()
        {
            IBlockHelper helper = HostFactory.Factory.GetBlockHelper();

            if (null == helper)
            {
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSBlock.AvailableBlockDefinitions"));
            }

            string[]       blockNames = helper.ListAllBlocksInCurrentDocument();
            List <DSBlock> blocks     = new List <DSBlock>();

            foreach (var name in blockNames)
            {
                DSBlock block = new DSBlock(name);
                blocks.Add(block);
            }
            return(blocks.ToArray());
        }
Example #4
0
 internal DSBlockInstance(DSCoordinateSystem contextCoordinateSystem, string blockName, bool persist)
     : base(DSBlock.InsertCore(contextCoordinateSystem, blockName), persist)
 {
     Definition = new DSBlock(blockName);
     ContextCoordinateSystem = contextCoordinateSystem;
 }
Example #5
0
 internal DSBlockInstance(DSCoordinateSystem contextCoordinateSystem, string blockName, bool persist)
     : base(DSBlock.InsertCore(contextCoordinateSystem, blockName),persist)
 {
     Definition = new DSBlock(blockName);
     ContextCoordinateSystem = contextCoordinateSystem;
 }
Example #6
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();
        }