Skip to main content
Best Answer

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

  • May 6, 2021
  • 7 replies
  • 192 views

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!

Best answer by caracadrian

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

caracadrian
Contributor
Forum|alt.badge.img+23
  • Contributor
  • Best Answer
  • May 6, 2021

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?


Forum|alt.badge.img+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.


caracadrian
Contributor
Forum|alt.badge.img+23
  • Contributor
  • May 10, 2021

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!


Forum|alt.badge.img+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