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 Custom Properties via event change

1 REPLY 1
Reply
Message 1 of 2
manuel_f_perezii
257 Views, 1 Reply

Adding Custom Properties via event change

Hi All, 

 

Hello to all.

 

I am just new to revit api. I've been checking some codes as well but I cannot find anything that can work on my scenario.

 

First how can you add custom parameters to this window.

image.png

I am trying to use the instance binding on this link(https://www.revitapidocs.com/2023/7978cb57-0a48-489e-2c8f-116fa2561437.htm) My problem is that  I am not sure how to create the DefinitionFile that i need to pass on this method. I am checking the DefinitionFile.Create but it seems that this method is deprecated?  

 

here is the code that I assume that can create the custom parameters on that dialog. Let me know if my assumptions are correct.

 

 

public bool SetNewParameterToInstanceWall(UIApplication app, DefinitionFile myDefinitionFile)
{
    // create a new group in the shared parameters file
    DefinitionGroups myGroups = myDefinitionFile.Groups;
    DefinitionGroup myGroup = myGroups.Create("MyParameters1");

    // create an instance definition in definition group MyParameters
    ExternalDefinitionCreationOptions option = new ExternalDefinitionCreationOptions("Instance_ProductDate", SpecTypeId.String.Text);
    // Don't let the user modify the value, only the API
    option.UserModifiable = false;
    // Set tooltip
    option.Description = "Wall product date";
    Definition myDefinition_ProductDate = myGroup.Definitions.Create(option);

    // create a category set and insert category of wall to it
    CategorySet myCategories = app.Application.Create.NewCategorySet();
    // use BuiltInCategory to get category of wall
    Category myCategory = Category.GetCategory(app.ActiveUIDocument.Document, BuiltInCategory.OST_Walls);


    myCategories.Insert(myCategory);

    //Create an instance of InstanceBinding
    InstanceBinding instanceBinding = app.Application.Create.NewInstanceBinding(myCategories);

    // Get the BingdingMap of current document.
    BindingMap bindingMap = app.ActiveUIDocument.Document.ParameterBindings;

    // Bind the definitions to the document
    bool instanceBindOK = bindingMap.Insert(myDefinition_ProductDate,
                                    instanceBinding, BuiltInParameterGroup.PG_TEXT);
    return instanceBindOK;
}

 

 

 

And second is. How can I get the values on the keynote params. I am checking the event on OnDialogBoxShowing but I am not sure how to get the values in the window. What I am planning is that whenever a user inputs on the keynote I will programmatically add a custom new parameters on that pop up dialog.

 

btw I am using revit 2023.

 

Hoping someone can help. thank you in advance.

1 REPLY 1
Message 2 of 2

You're using instance binding method & it should be type binding to do this. 

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

Post to forums  

Forma Design Contest


Rail Community