Ejemplo n.º 1
0
        /// <summary>
        /// Replaces existing macro feature with a new one preserving the parameters
        /// </summary>
        /// <typeparam name="TMacroFeature">Type of macro feature</typeparam>
        /// <param name="featMgr">Pointer to feature manager</param>
        /// <param name="feat">Pointer to feature to replace</param>
        /// <returns>Ne replaced feature</returns>
        public static IFeature ReplaceComFeature <TMacroFeature>(this IFeatureManager featMgr, IFeature feat)
            where TMacroFeature : MacroFeatureEx
        {
            if (feat == null)
            {
                throw new ArgumentNullException(nameof(feat));
            }

            var featData = feat.GetDefinition() as IMacroFeatureData;

            if (featData == null)
            {
                throw new NullReferenceException("Specified feature not a macro feature");
            }

            var model = featMgr.Document;

            object parameters = null;

            if (typeof(TMacroFeature).IsAssignableToGenericType(typeof(MacroFeatureEx <>)))
            {
                featData.AccessSelections(model, null);

                var paramsType = typeof(TMacroFeature).GetArgumentsOfGenericType(typeof(MacroFeatureEx <>)).First();
                IDisplayDimension[]        dispDims;
                IBody2[]                   editBodies;
                MacroFeatureOutdateState_e state;
                string[]                   dispDimParams;
                parameters = m_ParamsParser.GetParameters(feat, featData, model, paramsType,
                                                          out dispDims, out dispDimParams, out editBodies, out state);
                MacroFeatureParametersParser.ReleaseDisplayDimensions(dispDims);
            }

            return(featMgr.ReplaceComFeatureBase <TMacroFeature>(feat, parameters));
        }
Ejemplo n.º 2
0
 /// <inheritdoc cref="ReplaceComFeature{TMacroFeature}(IFeatureManager, IFeature)"/>
 /// <typeparam name="TParams">Type of parameters</typeparam>
 /// <param name="parameters">Parameters to assign to replaced feature</param>
 public static IFeature ReplaceComFeature <TMacroFeature, TParams>(this IFeatureManager featMgr, IFeature feat, TParams parameters)
     where TMacroFeature : MacroFeatureEx <TParams>
     where TParams : class, new()
 {
     return(featMgr.ReplaceComFeatureBase <TMacroFeature>(feat, parameters));
 }