-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dxf layer import exclusion not matching layer names properly #624
Comments
Definitely depends on what flavor of .dxf you feed in (there are a lot of flavors, so that's annoying). I wonder if this could/should be solved in ezdxf |
@greyltc If you think ezdxf may have changed this functionality in newer versions, you could try pinning an older version here and rebuild the Anaconda environment. DXF import is relatively new so it may just be that it's always been that way and nobody has noticed it until now. Enforcing a case for layer names sounds reasonable, but there may be problems with the approach that I'm not considering. |
Can you check on the ezdxf bug tracker? Seems that they do some "normalization": |
@greyltc I tried to reproduce the issue locally, but cannot. I have a DXF with upper and lower case names and filtering on it works as expected. Can you share your file? |
Yeah, I'll try to make up a minimally reproducible example for you, with file. |
Ok, I've made a minimal example files with a circle on After inspecting the contents of the files, it turns out that the layer name strings are actually all uppercase in the R14 .dxf file format (they're as expected in the R2018 one). So the case information is actually discarded at save time. Maybe the R14 ASCII standard doesn't support case sensitive layer names? |
as far as I'm aware, dxf layer names are not case sensitive in any version so they are normalised (to lower case) for use in the rendering context, but ezdxf returns the layer name in it's original case when you query it. For context, I helped write the ezdxf rendering code and reverse engineered the correct behavior from many dxf files I have access to. The official reference is very poor at precisely explaining things (probably intentionally) so 'whatever AutoCAD does' is the de-facto standard. |
Then it seems we should force case agreement here while we're comparing strings. |
@greyltc let's not be too hasty on this topic. It seems that there is software that does preserve names and ezdxf does seem to support it. I also cannot find anything in the spec about names (it is written in a terrible way though). From this point of view I could say that the root cause is related to the tool you used to save your DXF and not to CQ. Would you agree? |
if you want I can see what AutoCAD does with the dxf file where the layers differ only in case. From what I can remember it will treat the layers as the same. There may be other CAD applications which are case sensitive but these would be non-compliant and so not worth considering IMO. ezdxf lets you read the values exactly as they are stored in the dxf file but it's up to the application to handle the data properly, the same way that a html parser might let you see tag names with their original case but the browser is still case insensitive. |
I generated them with DraftSight. I've since tested AutoCAD and it behaves the same way (layer name strings converted to all upper case at save time, but only when saving as certain DXF flavors). I can also say that neither software (DraftSight nor AutoCAD) allows the user to name/create layers that differ only in case (error dialog appears when renaming/creating a layer that case-insensitive matches an existing layer's name). I'm constantly surprised by how faithful of a clone of AutoCAD DraftSight is. Seems like AutoCAD's source code must have leaked or something! |
more evidence is that this crashes: import ezdxf
def main():
doc = ezdxf.new()
layout = doc.modelspace()
doc.layers.new('ABc')
doc.layers.new('abc') # ezdxf.lldxf.const.DXFTableEntryError: LAYER abc already exists! and when this file is opened in autocad the entities appear to be on the same layer: import ezdxf
doc = ezdxf.new()
layout = doc.modelspace()
doc.layers.new('ABc')
layout.add_line((0, 0), (0, 1), {'layer': 'AbC'})
layout.add_line((1, 0), (1, 1), {'layer': 'abc'})
doc.saveas('/tmp/test.dxf') |
OK, thanks for the thorough investigations. I'm convinced! |
I'm having a problem with #442 in that ezdxf is returning layer names that are all upper case, so none of my layer name exclusions are matching.
Not really sure yet why this happening now, maybe exdxf changed or the DXF file format I'm using is somehow causing the layer names to become upper case.
Need to investigate a bit more. Maybe we should just force all the layer names we deal with to lower case to avoid case issues.
The text was updated successfully, but these errors were encountered: