private void OnFeatureInsertionCompleted(RoundStockFeatureParameters parameters, IPartDoc part, bool isOk)
        {
            if (isOk)
            {
                var feat = (part as IModelDoc2).FeatureManager
                           .InsertComFeature <RoundStockMacroFeature, RoundStockFeatureParameters>(parameters);

                Debug.Assert(feat != null);

                //swpuc only
                if (feat != null)
                {
                    int index        = 1;
                    var featNameBase = $"Stock Block Round for config {(part as IModelDoc2).IGetActiveConfiguration().Name}";
                    var featName     = featNameBase;
                    while ((part as IModelDoc2).FeatureManager.IsNameUsed(
                               (int)swNameType_e.swFeatureName, featName))
                    {
                        featName = featNameBase + index++;
                    }

                    feat.Name = featName;
                }
            }
        }
示例#2
0
        public void WriteToParameters(RoundStockFeatureParameters parameters)
        {
            parameters.Direction       = Conditions.Direction;
            parameters.CreateSolidBody = Conditions.CreateSolidBody;
            parameters.ConcenticWithCylindricalFace = Conditions.ConcentricWithCylindricalFace;
            parameters.ExtraRadius = ExtraMaterial.AdditionalRadius;

            double stockStep = 0;

            if (Rounding.UseCustomStep)
            {
                stockStep = Rounding.CustomStep;
            }
            else
            {
                switch (Rounding.StockStep)
                {
                case StockSteps_e.Step0:
                    stockStep = 0;
                    break;

                case StockSteps_e.Step1_16:
                    stockStep = 0.0015875;
                    break;

                case StockSteps_e.Step1_8:
                    stockStep = 0.003175;
                    break;
                }
            }

            parameters.StockStep = stockStep;
        }
        public void ShowPage(RoundStockFeatureParameters parameters, IPartDoc part, IFeature editingFeature, IMacroFeatureData featData)
        {
            m_CurrentParameters  = parameters;
            m_CurrentPart        = part;
            m_EditingFeature     = editingFeature;
            m_EditingFeatureData = featData;

            if (m_ActivePage != null)
            {
                m_ActivePage.Handler.DataChanged -= OnDataChanged;
                m_ActivePage.Handler.Closing     -= OnPageClosing;
                m_ActivePage.Handler.Closed      -= OnClosed;
            }

            m_CurrentViewModel = RoundStockViewModel.FromParameters(parameters);

            m_ActivePage = new RoundStockView(m_CurrentViewModel, m_App);

            m_ActivePage.Handler.DataChanged += OnDataChanged;
            m_ActivePage.Handler.Closing     += OnPageClosing;
            m_ActivePage.Handler.Closed      += OnClosed;

            m_ActivePage.Show();

            m_Model.ShowPreview(part, parameters.Direction, parameters.ConcenticWithCylindricalFace,
                                parameters.StockStep, parameters.ExtraRadius);
        }
示例#4
0
        public static RoundStockViewModel FromParameters(RoundStockFeatureParameters parameters)
        {
            var          step       = parameters.StockStep;
            var          customStep = false;
            StockSteps_e defStep    = StockSteps_e.Step0;

            if (step == 0)
            {
                defStep = StockSteps_e.Step0;
            }
            else if (step == 0.0015875)
            {
                defStep = StockSteps_e.Step1_16;
            }
            else if (step == 0.003175)
            {
                defStep = StockSteps_e.Step1_8;
            }
            else
            {
                customStep = true;
            }

            return(new RoundStockViewModel()
            {
                Conditions = new ConditionOptions()
                {
                    ConcentricWithCylindricalFace = parameters.ConcenticWithCylindricalFace,
                    CreateSolidBody = parameters.CreateSolidBody,
                    Direction = parameters.Direction
                },
                Rounding = new RoundingOptions()
                {
                    UseCustomStep = customStep,
                    StockStep = defStep,
                    CustomStep = step
                },
                ExtraMaterial = new ExtraMaterialOptions()
                {
                    AdditionalRadius = parameters.ExtraRadius
                }
            });
        }