Exporting elements IDs with ExportToPCF in python

Hello everyone, long time browser first time poster here.

I need help figuring out this script in CPython3. The project is in Revit2024 and I’m using Dynamo v.2.19.3. I’m not a coder, and I’m not familiar with CPython scripting at all and this is my first crack at it.

I’m attempting to translate THIS MACRO into Dynamo so that I can have dynamic filenames and filepaths without having to manually rename each set I export.

I’m having no luck with it. I’ve finally got to the point where it not longer throws syntax errors at me, but now it just sits there not outputting anything to the filepath specified. Makes me wish there was a database of API docs that are written in python, I just can’t seem to wrap my head around it.

I’m trying to have 3 inputs in this module, first one being a list of element IDs, second being a string of the filename to be saved and third is the current doc (I supposed that one doesn’t need to be an input, and I can just set it to current doc inside the python script, but once again I’m completely new to this).

Any help is appreciated.

My CPython3 code:

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript import \*
from Autodesk.Revit.DB import \*
from Autodesk.Revit.DB.Plumbing import \*
from Autodesk.Revit.DB.Fabrication import \* 


idsN = IN[0]
filenameN = IN[1]
docN = IN[2]

if not isinstance(idsN, list):
        idsN = [idsN]

def ExportToPCF(document, ids, filename):
        document = docN
        ids = idsN
        filename = filenameN

result = ExportToPCF(docN, idsN, filenameN)
       
      
OUT = result
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
from Autodesk.Revit.DB.Plumbing import *
from Autodesk.Revit.DB.Fabrication import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

TransactionManager.Instance.TransactionTaskDone()

ids = List[ElementId](uidoc.Selection.GetElementIds())

OUT = FabricationUtils.ExportToPCF(doc, ids, r"c:\temp\somefile.pcf")