-
Notifications
You must be signed in to change notification settings - Fork 99
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
Geometry.from_dxf can only ever import one shape #246
Comments
Hi @mfeif thanks for raising this. Are you able to provide the |
Sure thing. Here's a suitable file. This is what it looks like: Only the largest (by area) shape is imported via the |
I had a thought; if we go around the Seems like the detection of intersection and within there could be done while still preserving multiple polygons, though. 🤷 Maybe it's a feature request on that library? |
Hi @mfeif, I see that your geometry is not connected. sectionproperties isn't really designed around unconnected geometries as the warping analysis is invalid, see warning here. However you can still perform a geometric analysis and plastic analysis on unconnected geometries. If you have multiple connected regions, e.g. two rectangles directly adjacent to each other, my understanding is that this should work with I suspect |
Great, thanks for investigating this one @mfeif! @aegis1980 wondering if this is something that could be supported in cad-to-shapely? |
@mfeif and @robbievanleeuwen From what I can tell this arose from the need to batch analyzing The definition of
Geometry (the decorator should be there, but it is missing), and in that respect, it is behaving as expected. Data in the dxf is interpreted according to the definition of Geometry . For multiple closed polygons in a dxf file, the 1st is selected (I'm actually not sure of this logic). There may be a more elegant way to make this selection, but only one Geometry should be produced.
This perspective may be too rigid and maybe it is appropriate for a classmethod to return an array of objects, but I thought I would offer it up. Let me know your thoughts. |
Fair point, but I am using |
When I wrote cad-to-shapely, I put 'finding lots of shapes with holes' in the too hard box. Info is not implicit in 'dumb' 2d geometry so |
@normanrichardson with you on the A current workaround for users, although tedious, would be to export each region as a separate dxf files. Import these as multiple In terms of implementing the desired |
I'm not following about the hatches and so on. I think using the logic in |
Hey folks, We encountered similar problems when trying to write a test to discover if a After several days of trying things out, the only solution I could come up with was to create a network of shapely Polygons based on their connectivity to each other. Similarily, I think we had to solve a similar problem when dealing with overlapping geometries with a hole going through both geometries. I think we could use cad-to-shapely to import all geometries and perhaps by-pass the hole detection part. Does the hole detection assume that if a geometry is completely contained within another geometry it is a hole? To make this whole thing more complicated, is there not also the possibility of nested materials within each other which may or may not have a hole in them? I think that @mfeif is correct that it would be good if |
I agree this seems like the best approach. Do you see the best way forward as this?
@connorferster are you able to make a PR to |
I added in dev branch of cad_to_shapely Got some bits and bobs to sort out, then will try and tie in with section-properties @robbievanleeuwen At moment section-properties Also some complications arise when you consider if user wants to import multiple sections from a single dxf (list of |
Love your work @aegis1980! |
A CompoundGeometry for a multi-section DXF would work great! A user can access the individual geometries by indexing into the .geoms attribute.
I have a student right now who is doing this exact use case for his minor project so the fix will be welcome!
Many thanks!
… On Nov 1, 2022, at 00:06, Robbie van Leeuwen ***@***.***> wrote:
Love your work @aegis1980!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Describe the bug
When importing shapes from a clean/well-formed DXF file, only one shape is ever found.
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
When working with a clean/well-formed DXF file, .from_dxf() should be able to import multiple shapes for analysis.
Additional context
I have a clean DXF file with some closed polylines in it, and all other entities purged/removed. I can import this DXF into shapely. I can also import this file into the cad_to_shapely shim. In both cases, the multiple-shape geometry is preserved.
However, when I do the same via Geometry.from_dxf() only one shape ever comes back. Digging deeper into the code in from_dxf I found this:
Looking into find_holes, we find that this behavior is by design:
So by using this utility function, sectionproperties can never support more than one shape in a DXF. This is not a "bug" in cad_to_shapely, per-se, as its the desired behavior, but by using this utility function, we're throwing out data.
I went through the analogous process by hand, NOT throwing out polygons and manually made a CompoundGeometry object, and it worked:
(this showed a little thumbnail of an object in a Jupyter Notebook)
The text was updated successfully, but these errors were encountered: