Autodesk.Revit.DB.Document to FamilyDocument

Hello

I’m trying to extract values from families in a folder using designscript (or OOTB dynamo nodes).

Currently I’ve been able to open and close the family documents, but I can’t figure out how to “do stuff” inside the families.

My designscript looks like this:

familiesInDirectory = FileSystem.GetDirectoryContents(directoryPath,
														"*.rfa",
														true);

familyDocuments = Dictionary.ValueAtKey(familiesInDirectory, "files");

doesStringContain = String.Contains(familyDocuments, ".00", false);
filterByBoolMask = List.FilterByBoolMask(familyDocuments, doesStringContain);
trueInputs = Dictionary.ValueAtKey(filterByBoolMask, "in");
falseInputs = Dictionary.ValueAtKey(filterByBoolMask, "out");
openedFamilies = Applications.OpenDocumentFile(falseInputs, false, false,	true, false);

// Do stuff after families are open


closedFamilies = Applications.CloseDocument(openedFamilies, true);

Can anyone point me in the right direction?

I’ve tried the FamilyDocument.GetParameterValueByName(), but my code outputs a Autodesk.Revit.DB.Document, and it requires an Application.Revit.Document

Can I convert between the two?

1 Like

Hi,

Mostly people jump to python for this kind of thing? Or use custom nodes… Rhythm has one and it is open source (thanks JP! https://github.com/johnpierson/RhythmForDynamo/blob/master/src/Rhythm/Revit/Application/Application.cs)

If using the python node is acceptable to you, this thread maybe gives some pointers…

I am not an expert on design script, but I think part of the reason people jump to these other languages is the control they offer for working with the api (and other dlls).

There is this post? But it doesn’t make much sense to me. DesignScript Libraries - #4 by aclarke

Best of luck, let us know how you get on :slight_smile:

Mark

Hello @Mark.Ackerley

Thanks for the reply!

I think you’re correct, that this should be done i python or similar - I do C# plugins as well, and because of the connection with the API it’s solved pretty easy with that, however this was a challenge I was told to try and solve in Dynamo.

I’ll give the link threads you found a good read.

If it doesn’t work, I might just write a short custom node with C# to solve it - I haven’t dived into python yet, but maybe this was a good time to start as well.

Thanks for the input, I’ll get back with my solution :)!

1 Like

Hey,

It is an interesting question :slight_smile: if you have the time, there is an AU class DesignScript: Origins, Explanation, Illustration maybe is has some useful nuggets…

If you wouldn’t mind posting back your findings either way it would be a great resource for the community :slight_smile:

Mark

@Mark.Ackerley is right. Python may be the best way to go. Given your background with the API makes this a lot easier. In python, use “import” to leverage the majority of the Revit API references.