error "unknown property: ''filename'' is undefined!"

I have a script that converts PhisicalMaterial to MSFS2020 FlightSim material. But it gives me error "unknown property: "filename" is undefined!" in this part:

on PM pressed do
(
if (queryBox "Convert all Physical Materials to FlightSim Material ?\nNot undoable !" title:"Materials convertion" beep:false) then
(
for mat in (getClassInstances PhysicalMaterial) do --pour tous les matos
(
new_FSmat = FlightSim()
new_FSmat.basecolorTex = mat.mapM1.filename
if mat.bumpmap != undefined then new_FSmat.NormalTex = mat.bumpmap.normal_map.filename
new_FSmat.name = mat.name
replaceinstances mat new_FSmat
)