Ejemplo n.º 1
0
        /// <summary>
        /// Extension for <see cref="IAssemblyDoc.AddMate5(int, int, bool, double, double, double, double, double, double, double, double, bool, bool, int, out int)"/>
        /// </summary>
        /// <param name="doc"><see cref="IAssemblyDoc"/></param>
        /// <param name="mateType"><see cref="swMateType_e"/>配合类型</param>
        /// <param name="mateAlign"><see cref="MateAlignExtension"/>同向或者反向配合</param>
        /// <param name="flip">是否反转配合,只在距离配合时起作用</param>
        /// <param name="distance">距离参数 参数顺序:距离 最大距离值 最小距离值</param>
        /// <param name="gearRatioParam">齿轮配合参数 参数顺序:GearRatioNumerator GearRatioDenominator </param>
        /// <param name="angle">角度参数 顺序: 角度 角度最大绝对值 角度最小绝对值</param>
        /// <param name="forPostionOnly">仅使用位置</param>
        /// <param name="lockRotation">锁定位置</param>
        /// <param name="widthMateOption">宽度配合参数</param>
        /// <param name="error">错误</param>
        /// <param name="throwIfError">是否在错误时抛出异常,默认为抛出</param>
        /// <returns></returns>
        public static IMate2 AddMate5Ex(this IAssemblyDoc doc, swMateType_e mateType, MateAlignExtension mateAlign, bool flip, Tuple <double, double, double> distance, Tuple <double, double> gearRatioParam, Tuple <double, double, double> angle, bool forPostionOnly, bool lockRotation, swMateWidthOptions_e widthMateOption, out swAddMateError_e error, bool throwIfError = true)
        {
            int error_int;
            var mate = doc.AddMate5(mateType.SWToInt(), mateAlign == MateAlignExtension.SameAlign ? swMateAlign_e.swMateAlignALIGNED.SWToInt() : swMateAlign_e.swMateAlignANTI_ALIGNED.SWToInt(), flip, distance.Item1, distance.Item2, distance.Item3, gearRatioParam.Item1, gearRatioParam.Item2, angle.Item1, angle.Item2, angle.Item3, forPostionOnly, lockRotation, widthMateOption.SWToInt(), out error_int);

            error = error_int.CastObj <swAddMateError_e>();
            if (throwIfError && error != swAddMateError_e.swAddMateError_NoError)
            {
                throw new InvalidOperationException($"Mate Error:{error.ToString()}");
            }
            return(mate);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 面重合配合
        /// </summary>
        /// <typeparam name="TFaceOne"></typeparam>
        /// <typeparam name="TFaceTwo"></typeparam>
        /// <param name="doc"></param>
        /// <param name="faceOne"></param>
        /// <param name="faceTwo"></param>
        /// <param name="mateAlign"></param>
        /// <returns></returns>
        public static Mate2 AddFaceCoinMate <TFaceOne, TFaceTwo>(this IAssemblyDoc doc, TFaceOne faceOne, TFaceTwo faceTwo, MateAlignExtension mateAlign)
        {
            int   mateError = 0;
            Mate2 swMate    = default;

            SelectEntityOrFeature(faceOne, false);
            SelectEntityOrFeature(faceTwo, true);

            switch (mateAlign)
            {
            case MateAlignExtension.SameAlign:
                swMate = doc.AddMate5((int)swMateType_e.swMateCOINCIDENT, (int)swMateAlign_e.swMateAlignALIGNED, false, 0, 0, 0, 0, 0, 0, 0, 0, false, false, 0, out mateError);
                break;

            case MateAlignExtension.AntiAlign:
                swMate = doc.AddMate5((int)swMateType_e.swMateCOINCIDENT, (int)swMateAlign_e.swMateAlignANTI_ALIGNED, false, 0, 0, 0, 0, 0, 0, 0, 0, false, false, 0, out mateError);
                break;

            default:
                break;
            }
            return(swMate);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 面重合配合
        /// </summary>
        /// <typeparam name="TFaceOne"></typeparam>
        /// <typeparam name="TFaceTwo"></typeparam>
        /// <param name="doc"></param>
        /// <param name="faceOne"></param>
        /// <param name="faceTwo"></param>
        /// <param name="mateAlign"></param>
        /// <param name="dis">距离,正负代表方向</param>
        /// <returns></returns>
        public static Mate2 AddFaceDisMate <TFaceOne, TFaceTwo>(this IAssemblyDoc doc, TFaceOne faceOne, TFaceTwo faceTwo, MateAlignExtension mateAlign, double dis)
        {
            int   mateError = 0;
            Mate2 swMate    = default;

            SelectEntityOrFeature(faceOne, false);
            SelectEntityOrFeature(faceTwo, true);

            switch (mateAlign)
            {
            case MateAlignExtension.SameAlign:
                if (dis > 0)
                {
                    swMate = doc.AddMate5((int)swMateType_e.swMateDISTANCE, (int)swMateAlign_e.swMateAlignALIGNED, false, dis, dis, dis, 0, 0, 0, 0, 0, false, false, 0, out mateError);
                }
                else
                {
                    swMate = doc.AddMate5((int)swMateType_e.swMateDISTANCE, (int)swMateAlign_e.swMateAlignALIGNED, true, -dis, -dis, -dis, 0, 0, 0, 0, 0, false, false, 0, out mateError);
                }
                break;

            case MateAlignExtension.AntiAlign:
                if (dis > 0)
                {
                    swMate = doc.AddMate5((int)swMateType_e.swMateDISTANCE, (int)swMateAlign_e.swMateAlignANTI_ALIGNED, false, dis, dis, dis, 0, 0, 0, 0, 0, false, false, 0, out mateError);
                }
                else
                {
                    swMate = doc.AddMate5((int)swMateType_e.swMateDISTANCE, (int)swMateAlign_e.swMateAlignANTI_ALIGNED, true, -dis, -dis, -dis, 0, 0, 0, 0, 0, false, false, 0, out mateError);
                }
                break;

            default:
                break;
            }
            return(swMate);
        }