Exemple #1
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;

            uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;

            doc = uidoc.Document;
            sel = uidoc.Selection;
            ViewSheet viewSheet = doc.ActiveView as ViewSheet;
            string    sheetname = CegTitleBlockParameter.Instance.GetSheetName(viewSheet);

            if (viewSheet != null)
            {
                if (viewSheet.IsAssemblyView)
                {
                    try
                    {
                        AssemblyInstance assemblyInstance = doc.GetElement(viewSheet.AssociatedAssemblyInstanceId) as AssemblyInstance;
                        FamilyInstance   familyInstance   = Getstructulral(assemblyInstance);
                        Caculator(familyInstance);
                        this.Products            = GetProduct.GetAllProduct(doc);
                        this.AssemblySheetDict   = CegTitleBlockParameter.Instance.AssemblySheetDictionary(doc);
                        this.SheetTitleBlockDict = CegTitleBlockParameter.Instance.GetSheetTitleBlock(doc, out this.SheetParameterDict, out this.TitleBlockParameterDict, out this.ViewSheetDict, out this.SheetList);
                        using (Transaction tran = new Transaction(doc, "Add value"))
                        {
                            tran.Start();
                            foreach (KeyValuePair <string, CegParameterSet> item in SheetParameterDict)
                            {
                                if (item.Key.Equals(sheetname))
                                {
                                    foreach (var item2 in item.Value.Parameters.Values)
                                    {
                                        switch (item2.Name)
                                        {
                                        case "ENGDSN":
                                            Parameter parameter1 = viewSheet.LookupParameter(item2.Name);
                                            bool      flag1      = parameter1 == null || parameter1.IsReadOnly;
                                            if (!flag1)
                                            {
                                                SetParameter(parameter1, DESIGNSHT_ENGDSN);
                                            }
                                            break;

                                        case "HDLDSN":
                                            Parameter parameter2 = viewSheet.LookupParameter(item2.Name);
                                            bool      flag2      = parameter2 == null || parameter2.IsReadOnly;
                                            if (!flag2)
                                            {
                                                SetParameter(parameter2, HANDLINGSHT_HDLDSN);
                                            }
                                            break;

                                        case "TKT_WEIGHT":
                                            Parameter parameter3 = viewSheet.LookupParameter(item2.Name);
                                            bool      flag3      = parameter3 == null || parameter3.IsReadOnly;
                                            if (!flag3)
                                            {
                                                SetParameter(parameter3, PRODWT_TKT_WEIGHT);
                                            }
                                            break;

                                        case "PRDTCODE":
                                            Parameter parameter4 = viewSheet.LookupParameter(item2.Name);
                                            bool      flag4      = parameter4 == null || parameter4.IsReadOnly;
                                            if (!flag4)
                                            {
                                                SetParameter(parameter4, PRODTYPE_PRDTCODE);
                                            }
                                            break;

                                        case "STRIPPING_STRENGTH":
                                            Parameter parameter5 = viewSheet.LookupParameter(item2.Name);
                                            bool      flag5      = parameter5 == null || parameter5.IsReadOnly;
                                            if (!flag5)
                                            {
                                                SetParameter(parameter5, RELEASESTR_STRIPPING_STRENGTH);
                                            }
                                            break;

                                        case "28_DAY_STRENGTH":
                                            Parameter parameter6 = viewSheet.LookupParameter(item2.Name);
                                            bool      flag6      = parameter6 == null || parameter6.IsReadOnly;
                                            if (!flag6)
                                            {
                                                SetParameter(parameter6, DAYSTR_28_DAY_STRENGTH);
                                            }
                                            break;

                                        case "TKT_CUYDS":
                                            Parameter parameter7 = viewSheet.LookupParameter(item2.Name);
                                            bool      flag7      = parameter7 == null || parameter7.IsReadOnly;
                                            if (!flag7)
                                            {
                                                SetParameter(parameter7, BACKUPC_TKT_CUYDS);
                                            }
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                }
                            }
                            tran.Commit();
                        }
                    }
                    catch
                    {
                    }
                }
                return(Result.Succeeded);
            }
            else
            {
                return(Result.Cancelled);
            }
        }