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: 

Create Project Parameter(not shared parameter)

35 REPLIES 35
SOLVED
Reply
Message 1 of 36
Anonymous
21035 Views, 35 Replies

Create Project Parameter(not shared parameter)

i did search how to create a project parameter.

 

i found how to create a shared parameter.

 

but i can't find how to create a project parameter.

 

help me

35 REPLIES 35
Message 2 of 36
jeremytammik
in reply to: Anonymous

Sorry, as far as I know these cannot be created programmatically.

 

Best regards,

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 36
sobon.konrad
in reply to: jeremytammik

Is this still the case? In Revit 2016/2017 can we create Project Parameters that are not Shared Parameters? 

Message 4 of 36
jeremytammik
in reply to: sobon.konrad

Dear Konrad,

 

Thank you for your update to this request.

 

Sorry, that is still the case today.

 

We have an existing wish list item CF-3731 [API wish: programmatically create non-shared project parameter] for this functionality, which will require exploration and possibly a modification to our software. I added a note of your and BIMS_Keris' request to this item in order to make the development team aware of its importance. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide us with additional information at any time quoting this wish list item number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team, and prioritised against all of the other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 36
Anonymous
in reply to: jeremytammik

Hello,

 

but what about assign a Shared Parameter to certain system families, like Ducts? We assign it from the Project Parameter menu, yes, but we don't create it as a Project Parameter, but as Shared Parameter.

 

Thanks,

Message 6 of 36
Anonymous
in reply to: Anonymous

I mean, we would need to do this, being test.csv our shared parameters file:

 

Captura.PNG

Message 7 of 36
jeremytammik
in reply to: Anonymous

@Anonymous

 

You can bind shared parameters to almost any category you choose:

 

http://thebuildingcoder.typepad.com/blog/2016/12/material-shared-parameters-and-adn-xtra-labs.html

 

Check out Lab4_3_1_CreateAndBindSharedParam in the ADN Xtra labs:

 

https://github.com/jeremytammik/AdnRevitApiLabsXtra/blob/master/XtraCs/Labs4.cs#L511-L677

 

https://github.com/jeremytammik/AdnRevitApiLabsXtra

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 8 of 36
Anonymous
in reply to: jeremytammik

Has there been any update on this?

Message 9 of 36
Anonymous
in reply to: Anonymous

I'm a total Revit API n00b, but if I'm not totally at a loss here I think I managed to programmatically create a Project Parameter.

 

Stumbled upon this:

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

 

From where I copy pasted the following without any remorse:

public static void RawCreateProjectParameter(Application app, string name, ParameterType type, bool visible, CategorySet cats, BuiltInParameterGroup group, bool inst)
        {
            string oriFile = app.SharedParametersFilename;
            string tempFile = Path.GetTempFileName() + ".txt";
            using (File.Create(tempFile)) { }
            app.SharedParametersFilename = tempFile;

            var defOptions = new ExternalDefinitionCreationOptions(name, type)
            {
                Visible = visible
            };
            ExternalDefinition def = app.OpenSharedParameterFile().Groups.Create("TemporaryDefintionGroup").Definitions.Create(defOptions) as ExternalDefinition;

            app.SharedParametersFilename = oriFile;
            File.Delete(tempFile);

            Autodesk.Revit.DB.Binding binding = app.Create.NewTypeBinding(cats);
            if (inst) binding = app.Create.NewInstanceBinding(cats);

            BindingMap map = (new UIApplication(app)).ActiveUIDocument.Document.ParameterBindings;
            if (!map.Insert(def, binding, group))
            {
                Trace.WriteLine($"Failed to create Project parameter '{name}' :(");
            }
        }

Then using it like:

using (Transaction trans = new Transaction(doc))
                    {
                        // The name of the transaction was given as an argument
                        if (trans.Start("Create project parameter") != TransactionStatus.Started) return false;

                        Category materials = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Materials);
                        CategorySet cats1 = app.Create.NewCategorySet();
                        cats1.Insert(materials);

                        ParameterUtils.RawCreateProjectParameter(app, projectParameterName, ParameterType.Text, true,
                            cats1, BuiltInParameterGroup.PG_IDENTITY_DATA, true);
                        trans.Commit();

I think it worked.

- If I go to "Manage tab -> Settings panel -> (Project Parameters)" I can see the parameter.

- If I set a Property to material (via API) I can see the value when clicking "Material Browser -> Custom Parameters." I can see a new value in the UI.

Message 10 of 36
Anonymous
in reply to: Anonymous

Unfortunately, all that is doing is creating a new project parameter from a shared parameter (i.e., ExternalDefinition).  If it is an ExternalDefinition then it is a shared parameter.

There is still no way to create a project parameter from an Internal Definition. 

 

If you think about it for a bit, you probably don't ever want to create a project parameter (non-shared) programmatically anyway.  What happens when you do so, is that you could wind up in a situation (like I did a few years ago when I was less wise) and wound up with 5 "myParameter"s on each element...  The reason being that Revit doesn't care a wink about the name of the parameter, it only knows about the Guid of the parameter (open your shared param file in a text editor and see).  So when you're adding parameters to a file that you intend to work with, using the shared parameters method is vastly superior.  You will need to either add the definitons to a shared param file "manually" (through the Revit UI) or programatiicaly create the shared params file once (if you have many that can be programmed).  Then simply send that file along with your installer, path to it just before you need it and then add params from that file.  Then you'll know that you always have the right ones and you can even use their guid to make sure you are always reading and writing to the correct one.  

 

If you were able to use the project internal parameters workflow, you would open yourself to multiple params of the same name, and other issues.  From the user standpoint, they have no idea if a project parameter was created "internally" or from an external definition, it will look and work exactly the same (with exception of when you try to modify the parameter).  

 

I would strongly encourage you to consider the shared params only workflow for adding parameters to a revit file (regardless of how many categories you need to associate them with).  You can always switch to your shared params file before adding and then switch back to the previous after you're done adding params. 

 

Remember that the "current shared params" file is just a "phone book" which associates a guid with a name and type, nothing more.  So once you're done adding the definition to the file, switching back to the user's shared params file, will have no adverse effect.   (it's ONLY needed when you're actively adding a project or family param from the shared definition)

 

Does that clear up the issue at all?

Message 11 of 36
Anonymous
in reply to: Anonymous

Thanks for the heads up. 🙂 If anything, I will discuss with our client what is it that's actually wanted from this..

Message 12 of 36

The most needed for me is to be able to create the parameters for Key Schedules from API. At this moment the Key Schedules don't allow shared parameters. There is a discussion about that here:

 

https://forums.autodesk.com/t5/revit-ideas/allow-shared-parameter-in-a-key-schedule/idc-p/8358056#M2...

 

It would be great to have at least one solution of these two:

1 - Key Schedules allow shared parameters

2 - Project parameters can be created from Revit API

 

Without one of them, it´s impossible to create Key Schedules through Revit API including their parameters.

Message 13 of 36

This is exactly the same reason why we need this too!

Message 14 of 36
Anonymous
in reply to: jeremytammik

Is it still not in developers bunker?

Message 15 of 36

any news about this topic?

 

Regards, 

Message 16 of 36

I made this note a while back that may or may not help:

 

update with valid solution, because it can be done in dynamo!


cf. email [Create Project Parameter(not shared parameter) programmatically ?] 

 

[Q] I am trying to get rid of some of our Dynamo scripts, and one of the things we do is to create Revit properties. I wanted to do that in a revit plugin in C#, but then our dev stumbled upon this thread:

https://forums.autodesk.com/t5/revit-api-forum/create-project-parameter-not-shared-parameter/td-p/51...

It seems strange to me that something I can do in Dynamo would be impossible in C# using the Revit API…

That would mean I can’t do that with the Forge Design Automation too…

 

[A] If it can be done in Dynamo, then it can be done directly in a Revit add-in as well.

Dynamo is open source, so all you have to do is look at the source code to see how it is done.

The same can be achieved in a Revit add-in in C# or any other .NET language.

 

[R] This is what I thought too ! I think the forum thread might need an updated answer.

 

I will dig into https://github.com/DynamoDS/DynamoRevit and see what calls are made.

 

I suppose whoever promised to do that ended up busy with other things ...

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 17 of 36

I took a quick glance at the code for creating a project parameter. It turns out that to create a project parameter, they just create a temporary new shared parameters file, create a shared parameter in that file, import the shared parameter, then delete the temporary shared parameter file.

Message 18 of 36
jeremy_tammik
in reply to: Anonymous

Tricky Revit nomenclature...

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 19 of 36
wence.sui
in reply to: mhannonQ65N2

You're right, thanks for sharing!
Message 20 of 36
RPTHOMAS108
in reply to: mhannonQ65N2

So they are not creating a non shared project parameter just a shared one.

 

Would do away with non-shared project parameters (parameters only identified by name). The question regarding Key schedule is more about why can't you use shared parameters in them? Seems to be no obvious reason for this but they are not listed for some reason.

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

Post to forums  

Autodesk Design & Make Report