/// <summary> /// Checks if specified block exists in current file /// </summary> /// <param name="blockName">Name of the block</param> /// <returns>Returns true if the block exists else false</returns> public static bool Exists(string blockName) { if (string.IsNullOrEmpty(blockName)) { throw new ArgumentException(string.Format(Properties.Resources.InvalidInput, blockName, "DSBlock.Exists"), "blockName"); } IBlockHelper helper = HostFactory.Factory.GetBlockHelper(); if (null == helper) { throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSBlock.Exists")); } return(helper.BlockExistsInCurrentDocument(blockName)); }
internal static IBlockEntity InsertCore(DSCoordinateSystem contextCoordinateSystem, string blockName) { string kMethodName = "DSBlock.ByCoordinateSystem "; if (null == contextCoordinateSystem) { throw new ArgumentNullException("contextCoordinateSystem"); } if (contextCoordinateSystem.IsSheared) { throw new ArgumentException(string.Format(Properties.Resources.Sheared, "contextCoordinateSystem"), "contextCoordinateSystem"); } if (string.IsNullOrEmpty(blockName)) { throw new ArgumentException(string.Format(Properties.Resources.InvalidInput, blockName, kMethodName), "blockName"); } IBlockHelper helper = HostFactory.Factory.GetBlockHelper(); if (null == helper) { throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName)); } if (!helper.BlockExistsInCurrentDocument(blockName)) { throw new System.ArgumentException(string.Format(Properties.Resources.DoesNotExist, "DSBlock : " + blockName)); } IBlockEntity entity = helper.InsertBlockFromCurrentDocument(contextCoordinateSystem.CSEntity, blockName); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, kMethodName)); } return(entity); }