Solved

Read all DWGs in a folder and write to GDB with feature classes separated by DWG filename


Hello,

I'm looking to read all DWGs in a folder and convert them to feature classes inside one GDB, with the feature classes named as the DWG filenames. Currently, I've set my reader to read all DWGs in the folder and put as 'Single Merged Feature Type' so that it's a single input port. Then I followed this thread to use the FilenamePartExtractor transformer and set the fme_basename to the dwg file name. After it's run, it only outputs one feature class instead of multiple. See below for my workflow.

 fme cadtogdb 

Please advise on where I'm going wrong!

icon

Best answer by caracadrian 6 May 2021, 07:06

View original

7 replies

Badge +20

Use Directory and File Pathnames Reader witth the Path Filter Parameter set to .dwg followed by FeatureReader with Format set to DWG, Dataset set to path_windows attribute (or unix) and Accumulation Mode set to Merge Initiator and Result to keep the path_rootname attribute so you can use it in the GDB writer.

Use a geometry filter to separate the feature flow into point (and text), polygon, polyline.

Insert your GDB writer (or use a FeatureWriter) in witch you set Feature Class or Table Name in the text editor to @Value(path_rootname)_points. Duplicate it and set to @Value(path_rootname)_polylines and polygons (or variations of them).

GDB is sensitive to geometry type per table.

Use Directory and File Pathnames Reader witth the Path Filter Parameter set to .dwg followed by FeatureReader with Format set to DWG, Dataset set to path_windows attribute (or unix) and Accumulation Mode set to Merge Initiator and Result to keep the path_rootname attribute so you can use it in the GDB writer.

Use a geometry filter to separate the feature flow into point (and text), polygon, polyline.

Insert your GDB writer (or use a FeatureWriter) in witch you set Feature Class or Table Name in the text editor to @Value(path_rootname)_points. Duplicate it and set to @Value(path_rootname)_polylines and polygons (or variations of them).

GDB is sensitive to geometry type per table.

Thank you, this works great. However with this method the CAD attributes are lost, I'd like to retain autocad_layer for example. Is there a way to do this?

Badge +2

@propertiesc​ The pattern you have in your workspace should work. fme_basename should return the DWG file name without the .dwg, so you shouldn't need the FilenamePartExtractor .

To read multiple dwg files, use the Multiple Folder/File browser;

@propertiesc​ The pattern you have in your workspace should work. fme_basename should return the DWG file name without the .dwg, so you shouldn't need the FilenamePartExtractor .

To read multiple dwg files, use the Multiple Folder/File browser;

Hi Mark, fme_basename shows up with null values for the dwgs, I think this is a known bug, see here - https://community.safe.com/s/question/0D54Q000080hfGV/dwg-and-dgn-reader-not-exposing-fmebasename-and-published-parameter

Hence me looking for a workaround.

Badge +20

Thank you, this works great. However with this method the CAD attributes are lost, I'd like to retain autocad_layer for example. Is there a way to do this?

Use AttributeExposer.

Thank you, this works great. However with this method the CAD attributes are lost, I'd like to retain autocad_layer for example. Is there a way to do this?

Ahh beautiful thank you!

Badge +2

Hi Mark, fme_basename shows up with null values for the dwgs, I think this is a known bug, see here - https://community.safe.com/s/question/0D54Q000080hfGV/dwg-and-dgn-reader-not-exposing-fmebasename-and-published-parameter

Hence me looking for a workaround.

@propertiesc​  This should be fixed in FMe 2020.0 and later

Reply