Skip to main content

Hi everyone,

I'm working on a project where I need to process multiple IFC files and write the data to a PostgreSQL database using an FME workbench. I've written a Python script to automate this process, which includes getting IFC input from the user and executing the FME workbench. However, I'm encountering problems when passing multiple IFC files to the FME command line.

Any ideas?
 

Main Idea:

  1. Getting IFC Input from User: The script prompts the user to enter the path to a directory or a single IFC file.
  2. Running the FME Workbench: The script constructs and executes the FME command with the provided IFC file paths and other necessary parameters.

I am using a PythonCreator at the start of my FME script to catch these arguments and read with FeatureReader. Currently, when I look at the FME log after I run the external Python script, I see that the paths are not parsed as parameters. 

Main error I see in the log files is the following:
2024-06-21 21:52:52|   0.4|  0.0|ERROR |ISO10303-21: Unable to open STEP file: 'C:\Users\...\Desktop\sb_fme\new_data\...\Louna\16128_dp_haljastus.ifc C:\Users\...\Desktop\sb_fme\new_data\...\Louna\16128_dp_hoone.ifc C:\Users\...\Desktop\sb_fme\new_data\...\Louna\16128_dp_hoonestus.ifc C:\Users\...\Desktop\sb_fme\new_data\...\Louna\16128_dp_krunt.ifc C:\Users\...\Desktop\sb_fme\new_data\...\Louna\16128_dp_transp_klt.ifc C:\Users\...\Desktop\sb_fme\new_data\...\Louna\DP_Louna_plan-ala+krunt.ifc'. Please check that the file is readable.
 

External Python Script

 

 

Seems it can’t parse the list of files. The parameter is set to be able to have multiple files input, If you manually run that internal workspace with multiple IFC file inputs, at the start of the log will be a line for how to run that in command line, which will show the right formatting to pass into it. I’ve learned not to trust the GUI to be exactly right for filepath formatting because often it’ll autoformat after you enter values and click ok. FMEServerEmailGenerator for multiple attachments...

From memory, it’ll want the parameter value for multiple file inputs to be something like ““file.txt” “file.txt””, but maybe there’s some additional escaping required to do it this way.

 


I think configuring the feature reader to run on a single file should make it easier to have the python automate the batch process. Also, try making the path type parameter as a string user parameter…..this has fixed a lot of the formatting issues for me in the past instead of using one of the “File Format” options in the user parameter. That way, in python you can generate a full list of paths as strings into a python list and then just loop over that and send the single path objects into your workbench via user parameters. Then just adjust you workbench so the start is just a creator > attribute create (the path being submitted for the job > goes into feature reader > rest as normal.

I have made some posts in the past about invoking FME through subprocess that might be helpful as well:

 


The example I have in that post shows a basic for loop of a workbench running with 2 user parameters which are inputted from python: feature class name, and a file path for where to output the custom processing log. I think just configuring what you have slightly here should fix the issue.

 

Additionally, if you have many files to process, multiprocessing through python can be brought in to speed things up (if that is needed for your use case). But I think if you change it to a basic string user parameter and get all the paths you want to process in python first and then send that information to the workbench…..I think that should do the trick.


Reply