Not asking for code or anything just want to know if there is a reasonable path to go down to try to achieve this before I do a bunch of research in the API.
Is there a way to set a family’s default instance values back to the values in the family file?
The only way I can think of doing it involves getting into the family to get the values assigned to each type, but I don’t know if there is a easier way that wouldn’t require the family to open. Also don’t know how to take those values and set them as the defaults inside the project.
Certainly.
First the no-code old school way.
Open the original family (not project) and make a small change. Anything. Little line. Whatever. Reload. When prompted to overwrite parameters - do so. Done. You can then remove you small change and reload.
The code way.
Open the original family. You can do that ion the background so you don’t even see that action. Read the data from all the family types. Switch back to the project and set those values in the desired types. The only hiccup is if your family is using a type catalog. For that you can just read the catalog directly and apply that to the project.
I’ve tried the manual method with a detail component family and it did not set the instance default values back to the defaults. It still uses the value that was set when I did a create similar command.
As for the code method you described I don’t know how that would work. The only way I know of changing the default instance values for a family is to edit the values in the properties pallet before it is placed and that doesn’t do what I want anyway because that would set the default value for all types in the family not just the one currently selected. Additionally the properties pallet pre-placement for detail components in completely blank.
Basically, I’m trying to find where Revit stores the default values for instance parameters for families inside of projects and whether that value can be unique for each type in the family.
Since instances don’t exist until there is a real thing in the m,odel - you need to set the individual elements - not the types.
Old School Instance (Or not so old school)
Right click and Select all instances in project. Use the properties panel top reset the values. Done.
Programatiaclly
Select the instances (FiltteredElementColelctor). As before open the original family - get the value(s). Feed the values into each instance.
So a complete reset is a matter of updating both type parameters on the types. And instance parameters on the instances.
Revit stores the last value for instance placement for the next future instance. You can do some back and forth to reset that. But it gets reset as soon as someone paces something with a different value. And if you don’t want that to change all the time, it probably should have been a type parameter.
I don’t want to change the values of placed instances. I want to reset the default values for instance parameters per type.
We don’t want to use type parameters because the value needs to change sometimes. The default amps for a size 1 starter switch is 30 but sometimes it will need to be changed to a different value. Sometimes maybe it’s 20 or whatever. But because of this whenever someone a create similar on a size 2 the default value for amps becomes 60 for all types.
Revit clearly has some way of storing those type based instance default values because before someone uses create similar Revit knows that size 1 is 30 size 2 is 60 and size 3 is 200.
I may just tell people to deal with it and tweak the families once a update occurs that allows use to use text in formulas, because that is the only thing holding back another non-pyRevit solution of just having a type parameter base that can be overridden if a value is entered in a instance ‘input’ parameter. Something like “if(Amp=0,Amp Default, Amp)” except for text.
The values you are looking for are only stored in Revit memory for the current session. Not exposed to the end user.
The only real way to do that is to use an event driven program or an updater. Revit is always trying to change the value and you’re trying to change it back. In all honesty - it is a lot of overhead for what you’re accomplishing.
So you would need a hook to catch the start of the placement commannd.
command-before-exec[COMMAND_ID].py
Then you would switch to a different family type. Then back to the type you want and that should reset to the family default instance (essentially clearing the memory)
But this hook fires every time you place something. Bing, bing, bing, bing…
You’re users can do the same thing manually by switching type and switching back. But if they don’t want to type in a value, then they don’t want to switch a type.
The only real way to make this work well is to develop a custom family pallet and take complete control over the whole process from the start. But then everyone has to use that and not the native tools. Again a lot of effort for little payback.
I guess you could just tell them - restart Revit and the values will be back to the defaults.