示例#1
0
        /// <summary>
        /// There is no need to make a copy of bodies passed to this method.  Returns the first resulting body only.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="tool"></param>
        /// <param name="operation"></param>
        /// <returns>Return the first body of the result</returns>
        private Body2 BodyOperation(Body2 target, Body2 tool, swBodyOperationType_e operation)
        {
            var intersectBodies = (target.ICopy().Operations2((int)operation, tool.ICopy(), out int intError)) as object[];

            if (intError == 0) // swBodyOperationNoError
            {
                return(intersectBodies[0] as Body2);
            }
            else
            {
                if (intError == -1)
                {
                    throw new Exception("swBodyOperationUnknownError");
                }
                else
                {
                    var error = (swBodyOperationError_e)intError;
                    throw new Exception($"{error}");
                }
            }
        }