Ejemplo n.º 1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document        doc             = uidoc.Document;
            ElementSelector elementSelector = new ElementSelector();
            IList <Element> ilistElements   = elementSelector.SeclectManyElement(doc, uidoc);

            if (ilistElements == null)
            {
                return(Result.Succeeded);
            }

            ParameterProcess            parameterProcess            = new ParameterProcess();
            SampleCreateSharedParameter sampleCreateSharedParameter = new SampleCreateSharedParameter(doc, app);

            sampleCreateSharedParameter.LINK = @"C:\Users\OAI-IICM\Desktop\APIRevit-C#\Project\IICM\API_revit_IICM_1020\Define\Structural-Parameters.txt";
            foreach (Element ele in ilistElements)
            {
                shareParameters.Clear();
                listParamrter.Clear();
                shareParameters.AddRange(sampleCreateSharedParameter.GetListShareParamerter(ele));
                int loop = 1;
                id = 0;
                do
                {
                    foreach (Parameter para in ele.Parameters)
                    {
                        ParameterModel p = parameterProcess.GetParameterInformation(para, doc, id);

                        if (shareParameters.Contains(p.NAME))
                        {
                            listParamrter.Add(p);
                            id++;
                        }
                    }
                    if (listParamrter.Count > 0)
                    {
                        break;
                    }
                    sampleCreateSharedParameter.CreateSampleSharedParameters(ele);
                    ++loop;
                } while (loop < 2);;
                if (listParamrter.Count <= 0)
                {
                    TaskDialog.Show("IICM", ele.Id.ToString() + " no parameter!");
                    continue;
                }

                ///show dialog update param
                ///
                using (FormIO formIO = new FormIO(listParamrter))
                {
                    formIO.Text = ele.Id.ToString();
                    DialogResult dr = formIO.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        //do update
                        List <ParameterModel> listNewParam = new List <ParameterModel>();
                        listNewParam = formIO.VALUE;
                        foreach (var new_para in listNewParam)
                        {
                            parameterProcess.setParameterToElent(new_para.PARAMETER, doc, new_para.VALUE);
                        }
                    }
                }
            }



            return(Result.Succeeded);
            //throw new NotImplementedException();
        }