& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
1 min read
In a prior post, we showed how to output pipe fabrication parts to a PCF file. If you are using Assemblies in Revit to generate assembly views, and want to output a PCF of that assembly, you will find that you need to make some enhancements to the PCF output macro.
To do so, we will use a helper function (GetElementIdsInAssembly) to get the element IDs inside any selected assemblies.
Modify the original ExportSelectionToPCF function as shown below, and add the helper function (copy and paste from below).
After making these changes, you should be able to select a single assembly instance, and generate the required PCF output.
public void ExportSelectionToPCF() { // get the selected element ids List<ElementId> elementIdsToPCF = new List<ElementId>(); List<ElementId> selectedElementIds = this.ActiveUIDocument.Selection.GetElementIds().ToList(); elementIdsToPCF.AddRange(selectedElementIds); // add the element ids that are in assemblies List<ElementId> selectedAssemblySubElementIds = GetElementIdsInAssembly( selectedElementIds, this.ActiveUIDocument.Document); elementIdsToPCF.AddRange(selectedAssemblySubElementIds); // output the PCF Autodesk.Revit.DB.Fabrication.FabricationUtils.ExportToPCF( this.ActiveUIDocument.Document, elementIdsToPCF, "C:\\temp\\somefile.pcf"); } // Get the element ids in the selected assemblies public List<ElementId> GetElementIdsInAssembly( List<ElementId> selectedElementIds, Document theDocument) { List<ElementId> lstElemIds = new List<ElementId>(); foreach (ElementId id in selectedElementIds) { AssemblyInstance assemblyInst = theDocument.GetElement(id) as AssemblyInstance; if (assemblyInst == null) continue; lstElemIds.AddRange(assemblyInst.GetMemberIds()); } return lstElemIds; }
See Part 1: Exporting PCF Files from Revit 2018 to learn how to create a PCF file from Revit.
UPDATE: See how to export each assembly to a separate PCF file in this blog post
By clicking subscribe, I agree to receive the AEC newsletter and acknowledge the Autodesk Privacy Statement.
Success!
May we collect and use your data?
Learn more about the Third Party Services we use and our Privacy Statement.May we collect and use your data to tailor your experience?
Explore the benefits of a customized experience by managing your privacy settings for this site or visit our Privacy Statement to learn more about your options.