For opening and closing files I use @john_pierson Rhythm nodes… just like you
First, if files are already in the project then my node isnt needed. Next, why should files be open in background if you want them in your project? My node opens and close files (and upgrade if needed from previously versions) on the fly, but dont save them of course…
If you want upgrading including saving and loading at the same time you could try to combine @john_pierson nodes and mine
or… tweak my code as the following, then it will upgrade and save
the below line need to change
famDoc.Close(False) -> famDoc.Close(True)
#Copyright(c) 2014-2017, DanEDU Dynamo #Erik Falck Jørgensen, Technical University of Denmark (DTU) import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application #input assigned the IN variable paths = IN #wrap input inside a list (if not a list) if not isinstance(paths, list): paths = [paths] #ensure loaded families can overwrite existing families. class FamilyOption(IFamilyLoadOptions): def OnFamilyFound(self, familyInUse, overwriteParameterValues): overwriteParameterValues = True return True def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, overwriteParameterValues): source = FamilySource.Family overwriteParameterValues = True return True #core data processing for path in paths: try: famDoc = app.OpenDocumentFile(path) famDoc.LoadFamily(doc, FamilyOption()) famDoc.Close(True) except: pass #output assigned the OUT variable OUT = paths
Maybe we should take a close look at our workflow…
Current workflow (before/without Dynamo)
- We have a source directory with family files.
- We copy needed family files to project directory.
- We open the above families and edit their parameters.
- We save the edited families to the project directory.
- Then we load the families into the projectfile.
By skipping steps 2, 3 and 4 (edit the families once they are in the project) an accidental “save” command will overwrite the source families.
For now your solutions will do, and gave me something to think about.
I have nodes that could support that workflow. The family nodes works exact like that. Meaning that family files placed in a folder can be opened and get their parameters changed, and/or formulas, and/or added shared parameters in the order you choose. In combination with the open and close nodes in the rhythm package
Then load the families in a project subsequent
An example is shown below.
Eric, you’re the best
That’s exactly what i had in mind, you gave my rough ideas a boost.
One final question:
Would it be hard to edit the “DanEDU.File.LoadFamily” node to accept a “familyDocument” input, and give it a “document” output, like your other nodes.
If it’s a lot of work, forget it, you helped me more than enough.
On your request have I made a new node for loading families as family document. It can be used as shown below. Please update to the current DanEDU dynamo package.
BulkUpgradeLoad.dyn (13.2 KB)
All Family Document nodes…
Add parameters in family
Family document add shared parameter
Change Family parameter to shared parameter in ADSK family
Changing family type parameters and creating new types
Family Parameter Swap
Create Parameters in a Revit Family
Edit Formula Value in Project Environment for Multiple Families at Once
Different input for "Document.BackgroundOpen" node?
Now i’m totaly satisfied, a big bow for you
Thank you for your patience, and all the help.
Hi @erfajo, I’m starting again from your example (without python)… without result.
I’m experiencing problem just at the beginning of the script…
I can not really understand what is “i” filePath…
I was searching other topics, and thought the below link was worth mentioning.
Maybe the spaces in your path are the problem, as @Marcel_Rijsmus mentioned.
I hope it helps,
It is hard to say what goes wrong…I cant reproduce your problem.
However, if you have write protected folders or files it will fail… it is important that it does that, since only writable paths and files are usable.
The Directory.ContentsAll node is updated as shown below
First thank you for providing your package for Revit Dynamo.
I want to use an add shared parameter workflow based on your nodes. I rebuilded the workflow in Dynamo like in a picture of yours shown above (All Family Document nodes). But now there is occurring a failure. In the Family there never showing up new added parameters. The “DanEDU.FamilyDocument.AddSharedParameter”-Node says “An error occurred! Please veryfy setting”. Are my inputs not correct? All Shared Parameters are in the SPFile and its loaded to the Family. See my attached pictures. I would be very pleased if you can have a look and help me.
Best regards Dan
Shared parameter File detail: # This is a Revit shared parameter file. # Do not edit manually. *META VERSION MINVERSION META 2 1 *GROUP ID NAME GROUP 1 Schlüsselliste GROUP 2 Projektinformationen GROUP 3 Raumbuch GROUP 4 Luftmengenberechnung GROUP 5 Plankopf GROUP 6 Leistungsberechnung GROUP 8 HLS-Bauteile GROUP 9 Nutzungsvereinbarung
I am the one to blame for my usage of the SP file… so sorry for that. The thing is, I hated that I couldnt sort the content of the groups properly, so I tweaked the file… wups should not do that
that meas that my file looks like this:
# This is a Revit shared parameter file. # Do not edit manually. *META VERSION MINVERSION META 2 1 *GROUP ID NAME GROUP 1 01: Sheet & Project GROUP 2 02: Identity data GROUP 3 03: Constraints GROUP 4 04: Dimensions GROUP 5 05: Energy GROUP 6 06: Structural GROUP 7 07: Mechanical GROUP 8 08: IFC parameters GROUP 10 10: CCS Common Instance GROUP 11 11: CCS ID GROUP 12 12: CCS Common Type GROUP 15 15: Sigma GROUP 18 18: Dynamo GROUP 20 20: API Parameters GROUP 21 21: Exported Parameters
Thats why I must feed my group as “01: Sheet & Project”, but you should not do that, you should feed it as “3-Plan-Parameter”
Adding Shared Parameters to a family
Thank you for your fast response @erfajo !
Now i understand…! And it worked fine so far. Added my first Parameters to several Family-Files.
Made my Day
Have a nice Weekend later.
Thanks, and the same to you
…and sorry for the troubles you got for my pernickety behaviour in my SP file :-S
At the moment i’m creating a list Dynamo Player scripts (Revit 2018.1) from the above workflow.
I thought it would be nice to share some examples with you (for those who are interested).
02 PROJECT DIRECTORY_03 add shared parameters to families_STAIRCASE NUMBER_save.dyn (16.0 KB)
02 PROJECT DIRECTORY_03 add shared parameters to families_STAIRCASE NUMBER_update_save.dyn (17.7 KB)
02 PROJECT DIRECTORY_03 add shared parameters to families_STAIRCASE NUMBER_value_save.dyn (19.3 KB)
02 PROJECT DIRECTORY_03 add shared parameters to families_STAIRCASE NUMBER_value_update_save.dyn (21.0 KB)
I am trying to update a parameter name for an element within a family using a project directory. I don’t see a node that would accomplish this. Can you offer any help on this issue?
I am currently trying to change a material name from say “Glass” to “New Glass”.
The link below contains a picture of all “DanEDU” nodes you can use on a (background opened) FamilyDocument. So i guess “FamilyDocument.SetParameterByName” is the one you need.
Thank you for the quick response on the last post. This does work for what I need, but I wasn’t completely clear I suppose on what I need. I apologize.
I also need the ability to query what parameters are set up and what there values are in general, because the material I need to update is across multiple families and are set up on different parameter names across those families. A door might have the “glass material” set up under “Glass Parameter” and window family might have it set up under “Glazing Parameter”. Both need to be updated.
Do you know of a node that will accomplish this while working with the same FamilyDocument nodes?