Skip to main content
Question

Set ByLayer color (autocad_layer_color) in DWG.

  • May 1, 2019
  • 8 replies
  • 1087 views

nielsgerrits
VIP
Forum|alt.badge.img+60

What I want to do is to write a DWG, define the color of the lines ByLayer (autocad_color = 256) and set the Layer Color according to the feature. As the layer names are dynamically formed, I can not work with a template.

When reading the forums this seems not to be possible. But when reading the documentation, it looks like it is, as the "Used by Reader or Writer" column says Both.

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_ReadersWriters/acad/Feature_Representation.htm

So just to be sure, is it possible to get this to work? I could create a template on the fly and use that one if needed. Maybe a template in DXFR12, as that format is open?

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.

8 replies

chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • 606 replies
  • May 2, 2019

Hi @nielsgerrits,

Yes, setting the autocad_layer_color parameter to 256 will ensure that the feature uses the ByLayer color in the output DWG file. You can then set the layer color using the Default Color parameter in the writer parameters (under the Appearance section).

 


nielsgerrits
VIP
Forum|alt.badge.img+60
  • Author
  • 2938 replies
  • May 2, 2019

Hi @nielsgerrits,

Yes, setting the autocad_layer_color parameter to 256 will ensure that the feature uses the ByLayer color in the output DWG file. You can then set the layer color using the Default Color parameter in the writer parameters (under the Appearance section).

 

Hi Cris, thanx for your reaction. Do I understand correctly the Default Color cannot be set by an attribute?


chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • 606 replies
  • May 2, 2019

Hi Cris, thanx for your reaction. Do I understand correctly the Default Color cannot be set by an attribute?

Hi @nielsgerrits,

Yes, that is correct as far as I know. At the moment there is no way to set Default Color dynamically from an attribute value; however, this functionality has been suggested on the Ideas Page - it would be great if you can show your support by upvoting this idea. For now, I believe the only way is to specify a value for the Default Color parameter for each layer by using separate writer feature types for each layer in the output DWG or by using a template file.


nielsgerrits
VIP
Forum|alt.badge.img+60
  • Author
  • 2938 replies
  • May 3, 2019

Hi @nielsgerrits,

Yes, that is correct as far as I know. At the moment there is no way to set Default Color dynamically from an attribute value; however, this functionality has been suggested on the Ideas Page - it would be great if you can show your support by upvoting this idea. For now, I believe the only way is to specify a value for the Default Color parameter for each layer by using separate writer feature types for each layer in the output DWG or by using a template file.

Thanks for looking. I now fixed this with a workspacerunner, iterative generate a template file on the fly and then write the data.


nielsgerrits
VIP
Forum|alt.badge.img+60
  • Author
  • 2938 replies
  • May 3, 2019

In case anyone is looking for a solution, I worked around this by dynamically creating a template using a WorkspaceRunner.

Essentially I use 3 template folders, a,b,c. An empty template in a, gets copied to b, child writes dwg to c, based on the template in b, using parameters for layername and layercolor, then copies the result back to b. The child iterates through all layers. The parent finally writes the data to output, using the generated template in b.

FME 2019 poc in attached zipfile.

dynamictemplate.zip

Update:

Another alternative is to save the template as DXF12, as that version is open. Then using a text reader and writer expand the layer table. Some drawbacks, like uppercase layer names, as the format is quite old, but at least it can be done in a single workbench / job! I see several other interesting possibilities, like setting the extents.


becchr
Influencer
Forum|alt.badge.img+32
  • Influencer
  • 107 replies
  • June 15, 2020

In case anyone is looking for a solution, I worked around this by dynamically creating a template using a WorkspaceRunner.

Essentially I use 3 template folders, a,b,c. An empty template in a, gets copied to b, child writes dwg to c, based on the template in b, using parameters for layername and layercolor, then copies the result back to b. The child iterates through all layers. The parent finally writes the data to output, using the generated template in b.

FME 2019 poc in attached zipfile.

dynamictemplate.zip

Update:

Another alternative is to save the template as DXF12, as that version is open. Then using a text reader and writer expand the layer table. Some drawbacks, like uppercase layer names, as the format is quite old, but at least it can be done in a single workbench / job! I see several other interesting possibilities, like setting the extents.

thank you for sharing this, very helpful!


nielsgerrits
VIP
Forum|alt.badge.img+60
  • Author
  • 2938 replies
  • June 15, 2020

thank you for sharing this, very helpful!

Thanks for the feedback. It is a bit of a hassle for something that should be quite easy, but it works. For desktop, not for server.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • 2252 replies
  • June 15, 2020

I basicallly used LISP. (maybe the most ugly language i seen..)

Create auto macro on open to do it. (i remember posting it on the forum)

 

(i thnk 4 yrs ago. To bypass the fme limitation.)