Opened 7 years ago

Closed 6 years ago

#7009 closed enhancement (wontfix)

DXF: issue with symbol color on a entity referencing a block

Reported by: licas Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: dxf
Cc:

Description (last modified by licas)

cad version: cad2014

ide: vs2015

Precondition:source.dxf,destination.dxf

Program download link:https://drive.google.com/open?id=0BwOcIL25klCEcEVld3pQTkUyWUk

First i import the block from source.dxf to destination.dxf.And then i create a feature(geometry: point) in destioation.dxf(entity layer).The feature reference the block(feature->SetField("BlockName", "xx")) what i import from source.dxf. And i want to change the feature color. So i use feature->SetStyleString("SYMBOL(c:#00FF00)").When i done, i open the destination.dxf in cad. I found the color is not valid.

Is this a bug or my problem?

You can download the program in the above link(I build this program in vs2015), the program includes the source.dxf and destination.dxf(AddDxfBlock?\AddDxfBlock?\Debug\data),you can open in the cad2014.

Also i debug the code, i find the color is writed the dxf file.(OGRErr OGRDXFWriterLayer::WriteINSERT( OGRFeature *poFeature ))

I'm very sorry for any inconvenience.

Look forward to your reply.

update:2017-8-24

Now,i find some new thing。You can also find this words in the comment.

Let me say the result first.The block has a color attribute.In source.dxf block color attribute is "ByBlock".But when i import the block to destination.dxf. The block color attribute is various. Maybe it's the key point.So,there are something wrong when i import the block(source.dxf) to destination.dxf.(The source.dxf should be updated. Please download in the follow link).

I will to talk about this result in detail.The block has three color attributes('ByLayer', 'ByBlock' and color value) in CAD. ByLayer means when i drag the block into working area. The block's color will be the same as the Layer color. ByBlock means when i drag the block into working area. We can change the color in the properties panel(we can see the visual effect).So i modified the block in source.dxf(block layer).Change the color attribute to 'ByBlock'.I rebuild the destination.dxf.When i open the destination.dxf in CAD, there's no visual effect again(entity layer).So i check the block proeprties(block layer)in destination.dxf, i find the color attribute becomes various.(In the download file, i explain how to check the block properties(block layer)).

resource:​https://drive.google.com/open?id=0BwOcIL25klCEQW5YbXc4cU1VWEE

Change History (10)

comment:1 by Even Rouault, 7 years ago

I'm not a Autocad specialist, but if I look at source.dxf, I can see that the INSERT entity has no color property (code: 62), so I'm wondering if that makes sense to set one on INSERT entities (since the colors are set in the individual geometries that make the BLOCK that is inserted), although there is code in GDAL for both the read and write part to make use of the color attribute. Have you tried in Autocad to change the color of a INSERT and exporting to DXF. That could be interesting to compare it with destination.dxf. I've also tried with the free software QCad to open destination.dxf and it reports the green color in the properties (but there's no visual impact)

in reply to:  1 comment:2 by licas, 7 years ago

well,why i can't set the color property in the block of destination.dxf, because maybe i should set various color on some features in entity layer who reference the block(destinathion.dxf).

I've also open destination.dxf in cad and it reports the green color in the properties(but there's no visual impact).And i change the color in properties, there's no visual impact also. I must select the feature in the working area, and use the EXPLODE function.And then i change the color in the properties, it's ok.

So, i think there's something wrong in my code or in the gdal.

:)

Replying to Even Rouault:

I'm not a Autocad specialist, but if I look at source.dxf, I can see that the INSERT entity has no color property (code: 62), so I'm wondering if that makes sense to set one on INSERT entities (since the colors are set in the individual geometries that make the BLOCK that is inserted), although there is code in GDAL for both the read and write part to make use of the color attribute. Have you tried in Autocad to change the color of a INSERT and exporting to DXF. That could be interesting to compare it with destination.dxf. I've also tried with the free software QCad to open destination.dxf and it reports the green color in the properties (but there's no visual impact)

Last edited 7 years ago by licas (previous) (diff)

comment:3 by Even Rouault, 7 years ago

Resolution: invalid
Status: newclosed

Well what you say suggests that you should not probably try to change the color on the feature in the "entities" layer, but change it in the features of the "blocks" layer that you just copy from source currently.

It doesn't seem to me there's an issue in GDAL.

in reply to:  3 comment:4 by licas, 7 years ago

No,I think you misunderstand what i mean. I want to change the color on the feature in the "entities" layer.I don't want to change it in the features of the "blocks" layer.Sorry for my terriable english.

Replying to Even Rouault:

Well what you say suggests that you should not probably try to change the color on the feature in the "entities" layer, but change it in the features of the "blocks" layer that you just copy from source currently.

It doesn't seem to me there's an issue in GDAL.

comment:5 by Even Rouault, 7 years ago

I understood what you meant. Actually you managed to do what you wanted to do. You managed to change the color attribute of the feature in the entities layer. And when you opened it with AutoCad, it was reported to green in the attributes (which I also verified with QCAD). It is just that there's no visual effect on this, so this is not the proper way of changing the color of an entity that references a block. I've no idea if/how that can be done. But the behaviour you see seems to be rather logical to me. The visual appearance of an entity referencing a block should be mostly controlled by the content of the block itself. The entity just defines the anchor point. You should probably be look for help on a CAD forum. If you find a way to override the block color instanciated in the entity (without modifying the block content itself), then you can possibly come back with a DXF exported from Autocad so we can see how it is done.

Please also consider that the persons managing this bug tracker have limited time to do so, so avoid opening duplicates

in reply to:  5 comment:6 by licas, 7 years ago

I am so sorry for wasting you so much time ! I will to look for help on a CAD forum.

Replying to Even Rouault:

I understood what you meant. Actually you managed to do what you wanted to do. You managed to change the color attribute of the feature in the entities layer. And when you opened it with AutoCad, it was reported to green in the attributes (which I also verified with QCAD). It is just that there's no visual effect on this, so this is not the proper way of changing the color of an entity that references a block. I've no idea if/how that can be done. But the behaviour you see seems to be rather logical to me. The visual appearance of an entity referencing a block should be mostly controlled by the content of the block itself. The entity just defines the anchor point. You should probably be look for help on a CAD forum. If you find a way to override the block color instanciated in the entity (without modifying the block content itself), then you can possibly come back with a DXF exported from Autocad so we can see how it is done.

Please also consider that the persons managing this bug tracker have limited time to do so, so avoid opening duplicates

in reply to:  5 comment:7 by licas, 7 years ago

Hi, Even, I find some interesting thing in the CAD.Let me say the result first.The block has a color attribute.In source.dxf block color attribute is "ByBlock".But when i import the block to destination.dxf. The block color attribute is various. Maybe it's the key point.(The source.dxf should be updated. Please download in the follow link).

I will to talk about this result in detail.The block has three color attributes('ByLayer', 'ByBlock' and color value). ByLayer means when i drag the block into working area. The block's color will be the same as the Layer color. ByBlock means when i drag the block into working area. We can change the color in the properties panel(we can see the visual effect).So i modified the block in source.dxf(block layer).Change the color attribute to 'ByBlock'.I rebuild the destination.dxf.When i open the destination.dxf in CAD, there's no visual effect again(entity layer).So i check the block proeprties(block layer)in destination.dxf, i find the color attribute becomes various.(In the download file, i explain how to check the block properties(block layer)).

resource:https://drive.google.com/open?id=0BwOcIL25klCEQW5YbXc4cU1VWEE

Replying to Even Rouault:

I understood what you meant. Actually you managed to do what you wanted to do. You managed to change the color attribute of the feature in the entities layer. And when you opened it with AutoCad, it was reported to green in the attributes (which I also verified with QCAD). It is just that there's no visual effect on this, so this is not the proper way of changing the color of an entity that references a block. I've no idea if/how that can be done. But the behaviour you see seems to be rather logical to me. The visual appearance of an entity referencing a block should be mostly controlled by the content of the block itself. The entity just defines the anchor point. You should probably be look for help on a CAD forum. If you find a way to override the block color instanciated in the entity (without modifying the block content itself), then you can possibly come back with a DXF exported from Autocad so we can see how it is done.

Please also consider that the persons managing this bug tracker have limited time to do so, so avoid opening duplicates

comment:8 by Even Rouault, 7 years ago

Resolution: invalid
Status: closedreopened
Summary: DXF: SetStyleString (Symbol Color) invalidDXF: issue with symbol color on a entity referencing a block

I must confess I'm a bit lost whether there's some defect in GDAL or not. Or it is just that the AutoCAD concepts and OGR ones are just too far to be able to match them. You should probably investigate an API that is specific to DXF if you want precise control on it.

I re-open the ticket, in case someone else wants to address that, or just for reference if they hit that issue. As fas as I'm concerned, I won't probably act more on that ticket.

comment:9 by licas, 7 years ago

Description: modified (diff)

comment:10 by Alan Thomas, 6 years ago

Component: defaultOGR_SF
Keywords: dxf added
Resolution: wontfix
Status: reopenedclosed
Type: defectenhancement
Version: 1.11.4svn-trunk

OGR has no concept of "by block" and "by layer" colors. The DXF reader translates ByBlock and ByLayer color codes into the actual colors in which the objects are displayed by AutoCAD in the final render (the broken behaviour in GDAL 2.2 and earlier will be fixed in the 2.3 release). So the writer has no way of knowing when to output ByBlock and ByLayer color values, and when to output the actual displayed colors.

As a general point, the DXF writer will never be able to perform exact round-tripping of DXF files, particular when it comes to styling. The only way to overcome this, which I'm not interested in pursuing at this time, would be to add lots of fields to capture the many pieces of data that can't fit into a style string, like ByBlock and ByLayer values for the color, linetype, lineweight, and transparency fields, text upside-down and backwards flags, block base points, and so forth.

I'm going to make a call and change this into a "wontfix" enhancement ticket.

Note: See TracTickets for help on using tickets.