Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding Project Parameters

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Yoshiyuki_Miyauchi
605 Views, 2 Replies

Adding Project Parameters

I want to use the Revit API to add project parameters by referencing information in the shared parameter file.
Which API would help? I would be glad to know.

You found a post helpful? Then feel free to give likes to these posts!
Please click the Accept Solution button if my reply answers your question.
こちらの投稿は役に立ちましたか?良ければ「いいね」お願い致します!
こちらの投稿があなたの問題解決に寄与した場合、「解決策として承認」ボタンのクリックへのご協力をお願い致します。

Yoshiyuki Miyauchi / 宮内よしゆき
openBIM Architect
ONESTRUCTION Inc. Co-Founder & CTO
buildingSMART Japan IFC利用支援小委員会 委員長
bSI BIM Professional Certification | BSI BIM Project Information PRACTITIONER | BSI BIM Asset Information PRACTITIONER
Civil User Group認定インストラクター
y.miyauchi@onestruction.com | TEL:050-3528-8052
Twitter|LinkdIn
2 REPLIES 2
Message 2 of 3

こんにちは@Yoshiyuki_Miyauchi さん

 

Kindly follow below steps to add project parameter using Revit API.

1. Open SharedParameterFile

2. Get Group from SharedParameter File

3. Get Parameter

4. Filter Categories

5. Create Type/ Instance Binding

6. Bind parameter to project

 

Reference Code

 

 

//Revit Document Access
            Application app = commandData.Application.Application;
            UIApplication uiApp = commandData.Application;
            UIDocument uiDoc = uiApp.ActiveUIDocument;
            Document doc = uiDoc.Document;

            //SharedParameter File Path
            string path = @"C:\Users\XXXXX\Desktop\TextShared.txt";

            //Open SharedParameter File
            DefinitionFile defFile = app.OpenSharedParameterFile();

            ExternalDefinition parameter = null;

            //Get Group
            foreach (DefinitionGroup group in defFile.Groups)
            {
                if (group.Name == "Demo")
                {
                    Definitions extDefinitions = group.Definitions;

                    //Get Parameter
                    foreach (ExternalDefinition definition in extDefinitions)
                    {
                        if (definition.Name == "Demo Parameter")
                        {
                            parameter = definition;
                        }
                    }
                }
            }

            //Filter Categories
            Categories cat = doc.Settings.Categories;
            CategorySet set = new CategorySet();

            foreach (Category category in cat)
            {
                if (category.Name == "Walls")
                {
                    set.Insert(category);
                }
            }


            using (Transaction insert = new Transaction(doc, "add parameter"))
            {
                insert.Start();

                //Create Type Binding
                Binding type = app.Create.NewTypeBinding(set);

                //Bind Type Parameter
                BindingMap map = uiDoc.Document.ParameterBindings;
                map.Insert(parameter, type, BuiltInParameterGroup.PG_DATA);

                insert.Commit();
            }

 

 

 

 

Reference Links

https://spiderinnet.typepad.com/blog/2011/05/parameter-of-revit-api-31-create-project-parameter.html 

 

Hope this Will Helps 🙂

 

Thanks & Regards,
Mohamed Arshad K
Message 3 of 3

@Mohamed_Arshad san

Thank you!
That was very helpful.

You found a post helpful? Then feel free to give likes to these posts!
Please click the Accept Solution button if my reply answers your question.
こちらの投稿は役に立ちましたか?良ければ「いいね」お願い致します!
こちらの投稿があなたの問題解決に寄与した場合、「解決策として承認」ボタンのクリックへのご協力をお願い致します。

Yoshiyuki Miyauchi / 宮内よしゆき
openBIM Architect
ONESTRUCTION Inc. Co-Founder & CTO
buildingSMART Japan IFC利用支援小委員会 委員長
bSI BIM Professional Certification | BSI BIM Project Information PRACTITIONER | BSI BIM Asset Information PRACTITIONER
Civil User Group認定インストラクター
y.miyauchi@onestruction.com | TEL:050-3528-8052
Twitter|LinkdIn

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report