Question

Set ByLayer color (autocad_layer_color) in DWG.


Userlevel 6
Badge +32

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?


8 replies

Badge +2

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).

 

Userlevel 6
Badge +32

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?

Badge +2

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.

Userlevel 6
Badge +32

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.

Userlevel 6
Badge +32

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.

Userlevel 3
Badge +18

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!

Userlevel 6
Badge +32

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.

Badge +3

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.)

 

Reply