Extracting XML data from .RFA files

Extracting XML data from .RFA files

mikkelnymand4EMUM
Participant Participant
576 Views
1 Reply
Message 1 of 2

Extracting XML data from .RFA files

mikkelnymand4EMUM
Participant
Participant

Hello everyone, 

 

I'm trying to get the XML data that is contained within a .rfa file, however I would like to do this without the 'ExtractPartAtomFromFamilyFile' method. 

 

First of all, using the ExtractPartAtomFromFile method yields an error 

 

 

Autodesk.Revit.Exceptions.InternalException: 'Failed to extract PartAtom from the family file.'

 

 

 

I followed the example found at: The Building Coder but without luck. 

 

Secondly, I would like to manage these XML files from outside of Revit so not using Revit API is preferable, but acceptable if necessary. 

 

Reading the binary file and trying to extract the XML part has not yielded any good results yet either. 

 

My current code looks like this: 

 

 

UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;


            // Find revit family file 
            string folderPath = "C:\\Users\\mbny\\Desktop\\Revitudvikling";
            string filename = "M_Upper Cabinet-Corner Unit-Wall.rfa";
            string fullPath = folderPath + "\\" + filename;

            Transaction trans = new Transaction(doc,
              "Extract Part Atom");

            trans.Start();
            app.ExtractPartAtomFromFamilyFile(
              fullPath, fullPath + "\\" + "createdXML.xml");
            trans.Commit();

            return Result.Succeeded;

 

 

 

Has anyone solved this successfully? I'm planning on doing this on a very large number of family files, and quite often as well. 

 

 

0 Likes
Accepted solutions (1)
577 Views
1 Reply
Reply (1)
Message 2 of 2

mikkelnymand4EMUM
Participant
Participant
Accepted solution

Found a solution that fits my needs for now courtesy of https://www.summonidea.com/extracting-atomxml-from-revit-family/