Get (and ideally set) DWG/DXF Export settings layer modifiers

Hi all,

I’m trying to verify, and ideally automatically fill-in missing DWG/DXF Settings layer modifier settings after having imported these from another Revit file using Transfer Project Settings.
What we found is that if our other Revit file, e.g. a template, doesn’t have all the layers which are present in the file which we insert the DWG/DXF settings to, some layer modifiers which we use are not included.

I found this topic from 2018 which allows to read information from the layers tab of the DWG/DXF Settings tab and I’ve been able to extend that further, but I’m not sure how to extract information from the Autodesk.Revit.DB.LayerModifier values it gives me.

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

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

settings = IN[0]
if not isinstance(settings, list):
    settings = [settings]

def getExportInfo(set):
    layername = []
    layermodifiers = []  # List for layer modifiers
    cutlayermodifiers = []  # List for cut layer modifiers

    options = set.GetDWGExportOptions()
    table = options.GetExportLayerTable()
    keys = table.GetKeys()
    layerinfo = table.GetValues()

    for i in layerinfo:
        layername.append(i.LayerName)

        # Retrieve layer modifiers and cut layer modifiers
        layermodifiers_list = i.GetLayerModifiers()  
        cutlayermodifiers_list = i.GetCutLayerModifiers()

        layermodifiers.append(layermodifiers_list)
        cutlayermodifiers.append(cutlayermodifiers_list)

    return zip(layername, layermodifiers, cutlayermodifiers)

exportSettings = [getExportInfo(UnwrapElement(i)) for i in settings]

OUT = exportSettings

Revit API Docs: GetLayerModifiers Method & GetCut LayerModifiers Method

2025-01-19 Extract DWG-DXF Settings layermodifer information.dyn (11.7 KB)

Ideally, for all layers where applicable/possible I would like to set the layer modifier as {Phase_Created)_{Phase_Demolished} programmatically.