cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

include would probably be more useful than exclude for `_importDXF`

Open greyltc opened this issue 3 years ago • 2 comments

Sketches are awesome. Importing DXFs is awesome. _importDXF and its spawn seem kinda hard to use in practice. Generally, I know the names of the layers I want from a drawing. Some drawings have a lot of layers and generally I don't know the names of all the layers I don't want. Since the function takes a list of layer names to exclude from the import, what I've been doing is figuring out the exhaustive list of layer names in the drawing (via my own calls to ezdxf), then subtracting away the names of layers I want. Doing that is alright, but I think it'd be more useful and intuitive if the function took a list of layers to retrieve rather than the list of layers to not retrieve.

https://github.com/CadQuery/cadquery/blob/6217431d9865ec4f0e0bb9ecf7dfd1aa204fe809/cadquery/occ_impl/importers/dxf.py#L160-L182

greyltc avatar Apr 13 '22 20:04 greyltc

I'm happy to submit a PR to address this if I hear agreement that an API change like this would be alright.

greyltc avatar Apr 14 '22 07:04 greyltc

That would be great. Maybe such a signature would be a good compromise:

 def _importDXF(filename: str, tol: float = 1e-6, exclude: Optional[List[str]] = None, include: Optional[List[str]] = None) -> List[Face]: 

if both include and exclude are not None- throw.

adam-urbanczyk avatar Apr 14 '22 16:04 adam-urbanczyk