Exemplo 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));
        }
Exemplo n.º 2
0
 private SwMacroFeature <TParams> ToParameters <TParams>(MacroFeatureParametersParser paramsParser)
     where TParams : class, new()
 {
     return(new SwMacroFeature <TParams>(m_Doc, m_FeatMgr, Feature, paramsParser, IsCommitted));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Base constructor. Should be called from the derived class as it contains required initialization
 /// </summary>
 public MacroFeatureEx()
 {
     m_ParamsParser = new MacroFeatureParametersParser(this.GetType());
 }
Exemplo n.º 4
0
 internal SwFeatureManager(SwDocument doc)
 {
     Document       = doc;
     m_ParamsParser = new MacroFeatureParametersParser(doc.App.Sw);
 }
Exemplo n.º 5
0
 internal SwMacroFeature <TParams> ToParameters <TParams>(MacroFeatureParametersParser paramsParser)
     where TParams : class, new()
 {
     return(new SwMacroFeature <TParams>(m_Model, m_FeatMgr, Feature, paramsParser, IsCreated));
 }
Exemplo n.º 6
0
 internal SwFeatureManager(SwDocument model, IFeatureManager featMgr, ISldWorks app)
 {
     m_Model        = model;
     m_ParamsParser = new MacroFeatureParametersParser(app);
     m_FeatMgr      = featMgr;
 }
Exemplo n.º 7
0
 static FeatureManagerEx()
 {
     m_ParamsParser = new MacroFeatureParametersParser();
     m_App          = Context.CurrentApp;
 }
Exemplo n.º 8
0
 internal SwFeatureManager(SwDocument doc, ISwApplication app)
 {
     m_App          = app;
     Document       = doc;
     m_ParamsParser = new MacroFeatureParametersParser(app);
 }
 static MacroFeatureDataEx()
 {
     m_ParamsParser = new MacroFeatureParametersParser();
 }