Skip to main content
Solved

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

  • February 10, 2023
  • 2 replies
  • 102 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? 

 

Best answer by jovitaatsafe

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.

View original
Did this help you find an answer to your question?

2 replies

jovitaatsafe
Safer
Forum|alt.badge.img+11
  • Safer
  • Best Answer
  • February 14, 2023

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.


  • Author
  • February 15, 2023

Hi @jovitaatsafe​,

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

Cheers!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings