/// <summary> /// Instantiates the specified block by name with the orientation /// specified by the coordinate system into the target file. /// If the block does not exist in the target file, the block will be exported to the /// target file first. /// If the block already exists in the target file, the old block will be replaced with /// the new one. /// </summary> /// <param name="contextCoordinateSystem"> /// Specifies the orientation of the block. Origin is the placement point. /// This coordinate system must be orthogonal, can be non-uniformly scaled /// </param> /// <param name="targetFileName">the outside file name</param> /// <returns>If the insertion succeeds, returns true</returns> public bool ByCoordinateSystem(DSCoordinateSystem contextCoordinateSystem, string targetFileName) { 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(targetFileName)) { throw new ArgumentException(string.Format(Properties.Resources.InvalidInput, Name, kMethodName), "blockName"); } targetFileName = DSGeometry.GetFullPath(targetFileName); IBlockHelper helper = HostFactory.Factory.GetBlockHelper(); if (null == helper) { throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName)); } return(helper.InsertBlockInTargetFile(contextCoordinateSystem.CSEntity, Name, targetFileName)); }