/// <summary> /// 先检查是否能添加此种类型的约束,然后确定是否添加约束 /// </summary> /// <param name="skeRelMgr"><see cref="ISketchRelationManager"/> Interface</param> /// <param name="swConstraintType"><see cref="swConstraintType_e"/></param> /// <param name="sketchRelationResult"><see cref="ISketchRelation"/> 输出参数</param> /// <param name="entities">需要被约束的草图实体</param> /// <returns></returns> public static bool TryAddRelationEx(this ISketchRelationManager skeRelMgr, swConstraintType_e swConstraintType, out ISketchRelation sketchRelationResult, params object[] entities) { var consTypes = skeRelMgr.GetAllowedRelationsEx(entities); if (consTypes.Contains(swConstraintType)) { sketchRelationResult = skeRelMgr.AddRelationEx(swConstraintType, entities); return(true); } else { sketchRelationResult = null; return(false); } }
/// <summary> /// 添加草图约束 /// </summary> /// <param name="skeRelMgr"><see cref="ISketchRelationManager"/> Interface</param> /// <param name="swConstraintType"><see cref="swConstraintType_e"/> Relation type 约束类型</param> /// <param name="entities">需要被约束的实体</param> /// <returns></returns> public static ISketchRelation AddRelationEx(this ISketchRelationManager skeRelMgr, swConstraintType_e swConstraintType, params object[] entities) { //使用DispathWrapper 防止产生访问不可访问的内存的异常 return(skeRelMgr.AddRelation(ComWrapper.ObjectArrayToDispatchWrapper(entities), swConstraintType.SWToInt())); }