Hi @frahaman7SKBG. I haven't tested this yet, so be careful, because I don't use BIM stuff. But in theory the following simpler iLogic code should work for you if you just want to export the main assembly. It simply captures the currently 'active' assembly document, then uses the same path and file name as that assembly, but with the ".rfa" file extension when exporting the rfa file. If you need to change the path or file name further, you can change the line defining oFFN, or use multiple more lines to manipulate the string (text).
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
'gets the 'active' assembly document
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
'same path & file name as active assembly, but with ".rfa" file extension
Dim oFFN As String = System.IO.Path.ChangeExtension(oADoc.FullFileName, ".rfa")
'export
oADef.BIMComponent.ExportBuildingComponent(oFFN)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)