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
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Sorry, as far as I know these cannot be created programmatically.
Best regards,
Is this still the case? In Revit 2016/2017 can we create Project Parameters that are not Shared Parameters?
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:
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
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,
@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
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.
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?
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:
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.
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 ...
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.
Tricky Revit nomenclature...
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.