Solved

How to read the styling properties (color, linetype, lineweight) of a DWG layer

  • 10 February 2023
  • 2 replies
  • 7 views

Is there a possibilty to directly read the "styling" properties of a DWG layer in FME? By styling properties I mean e.g. the color, linetype, and lineweight.

 

I know that with the FeatureReader transformer, I can read the so-called "Schema Features". These Schema Features correspond to the layers in the DWG file (also see accepted solution at https://community.safe.com/s/question/0D5Dm000006a48rKAA/read-all-layer-names-from-dwg-files).

 

Unfortunately, at least with standard reader options, these Schema Features do not have any styling properties associated with them:

01_Properties of a Feature Schema object 

As a workaround, I could read the Data Features of the DWG file with e.g. a standard RealDWG reader (Autodesk AutoCAD RealDWG DWG/DXF) and activate the option 'Store Layer Properties on Features' in the reader properties:

02_Store Layer Properties on FeaturesThen, the single Data Features have corresponding attributes with the information on their layer's styling properties:

03_Layer_Information_on_Data_FeaturesHowever, this workaround has some limitations (e.g. if there are no Data Features on a specific layer).

 

Does anyone have an idea? 

 

icon

Best answer by jovitaatsafe 14 February 2023, 19:54

View original

2 replies

Badge +11

Hi @lbd-kufers​,

Good question! Unfortunately the answer is as you suspected: there needs to be a feature in each layer of the template in order to read in the styling information into FME, as suggested by this previous Q&A thread.

 

I recently answered a similar question and had put together a workspace that adds a line feature to each layer of a template file, and you can find it attached here.

 

The workspace looks something like this:

  • Use a Creator (to create a line feature) + FeatureReader (with the AutoCAD DWG/DXF reader) to get the number of feature types /layers from the Schema output port
  • Get the count and make that many clones
  • Give the clones a Count for an ID to join with layer names so that each clones has one unique layer name
  • Write out using a feature type fanout with the template set on the writer. You can set the output file extension to .dwt

 

Add_line_to_ea_dwg_layerWe have an enhancement request to ask for support for reading autocad template layer definitions tracked internally as (FMEENGINE-76295) and I'll update here when it has been addressed.

 

Hopefully that helps ease things up a bit more than going into AutoCAD to add a feature for each layer.

Hi @jovitaatsafe​,

thank you very much for reply, that is very helpful.

Cheers!

Reply