Exemplo n.º 1
0
        protected override MacroFeatureRebuildResult OnRebuild(ISldWorks app, IModelDoc2 model,
                                                               IFeature feature, RoundStockFeatureParameters parameters)
        {
            var cylParams = GetCylinderParams(model, parameters);

            //temp
            SetProperties(model, parameters, cylParams);
            //

            parameters.Height = cylParams.Height;
            parameters.Radius = cylParams.Radius;

            var featData = feature.GetDefinition() as IMacroFeatureData;

            MacroFeatureOutdateState_e state;

            SetParameters(model, feature, featData, parameters, out state);

            if (state != MacroFeatureOutdateState_e.UpToDate)
            {
                app.ShowBubbleTooltip("Stock Master",
                                      $"'{feature.Name}' feature is outdated. Edit definition of the feature to update",
                                      BubbleTooltipPosition_e.TopLeft, Resources.warning_icon);
            }

            if (parameters.CreateSolidBody)
            {
                var body = m_StockModel.CreateCylindricalStock(cylParams);
                return(MacroFeatureRebuildResult.FromBody(body, feature.GetDefinition() as IMacroFeatureData));
            }
            else
            {
                return(MacroFeatureRebuildResult.FromStatus(true));
            }
        }
        private void OnPageClosing(swPropertyManagerPageCloseReasons_e reason, SwEx.PMPage.Base.ClosingArg arg)
        {
            if (reason == swPropertyManagerPageCloseReasons_e.swPropertyManagerPageClose_Okay)
            {
                IBody2 body = null;

                Exception err = null;

                try
                {
                    var cylParams = m_Model.GetCylinderParameters(m_CurrentPart, m_CurrentParameters.Direction,
                                                                  m_CurrentParameters.ConcenticWithCylindricalFace,
                                                                  m_CurrentParameters.StockStep, m_CurrentParameters.ExtraRadius);

                    body = m_Model.CreateCylindricalStock(cylParams);
                }
                catch (Exception ex)
                {
                    err = ex;
                }

                if (body == null)
                {
                    arg.Cancel       = true;
                    arg.ErrorTitle   = "Cylindrical Stock Error";
                    arg.ErrorMessage = err?.Message;
                }
            }
        }