-
Notifications
You must be signed in to change notification settings - Fork 56
Implement DXF Importing #173
Comments
Added a starting point. I have a whole zip file of all of the american steel shapes, and all of the 8020 shapes once we get this going! |
I have started poking around with the code in the DXF branch. The following is a rough start at this only, of course.
What I've done in the above code is:
I'm running into a problem with the 1515-ULS.dxf test file though. That is the resulting step file opened in SolidWorks. It's missing the 2 end faces. Without the center hole, things work as expected: I am unsure how to solve this issue. Does FreeCAD or CQ have a notion of wire orientation? Or perhaps I am just misusing available functions in CQ? Has this problem been addressed somehow in the extrude functions? |
that's a great start. I think your approach is good. sortWiresByBuildOrder should return the outerwire first, but for extrusion i dont think it matters. I think i see the problem. in the example, the inner contour doesnt look like its closed. The upper-right of the 'star' appears to be missing: That could be an issue where the last contour is not being closed or whatever? |
This problem could be related to #83 I'm pretty sure that in some cases there's a glitch in how FreeCAD or OCC sort/order wires and edges. I've never had the time to dig into the FreeCAD internals to see where it comes from though. |
Ah i see ok. Well, this is a really really great first try. I'm
disappointed to be running into a glitch, though i guess its a good thing
we started with a complex enough example to bring it to the surface.
I'm pretty sure it doesnt have anything to do with your code-- the solution
is probably inside or around the wire sorting code (sortWiresByBuildOrder).
It appears that when i wrote this, i may have even known this is an issue--
I can't remember writing this, but inside of sortWiresByBuildOrder, i say:
Assume:
The wires make up one or more faces, which could have 'holes'
Outer wires are listed ahead of inner wires
there are no wires inside wires inside wires
( IE, islands -- we can deal with that later on )
none of the wires are construction wires
FreeCAD should be smart enough to nest wires inside each other and figure
things out, but it clearly isnt. My hunch is that FreeCAD is expecting
the order of the edges to be in a particular order, and that it assumes the
normal direction based on that order. The theory would be that the order
of the edges in the 'star' wire are somehow backwards, causing FreeCAD to
think the material direction is in the wrong direction. My comments in
extudeLinear
<https://github.com/dcowden/cadquery/blob/master/cadquery/freecad_impl/shapes.py#L846>
imply
that I ran into this during development.
To test this theory, I would recommend reversing the order of the edges in
the 'star'. To do this, you can use Wire.assembleEdges() to control the
order of the edges by hand, and see if it magically fixes it. If it does,
that means that to get this to work, we'll have to do the work we expect
FreeCAD to be doing, and manually order the edges and the wires correctly.
That really stinks.
…On Tue, Nov 28, 2017 at 8:55 PM, Jeremy Wright ***@***.***> wrote:
This problem could be related to #83
<#83>
I'm pretty sure that in some cases there's a glitch in how FreeCAD or OCC
sort/order wires and edges. I've never had the time to dig into the FreeCAD
internals to see where it comes from though.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#173 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABPOA5x7j_wz_cvn-gjLuXaU3M1so6tpks5s7LmMgaJpZM4LKDOf>
.
|
Hi @dcowden @jmwright @RustyVermeer |
@easyw thanks a bunch for this! That looks like just what we need. |
...oh except I'd rather not import openscad code to solve it... Perhaps we can use the same approach but realized using the embedded occ code. I think occ has a function that organizes edges as well |
please let me know which is in case you find it 😄 |
@easyw @RustyVermeer ShapeAnalysisWire and ShapeAnalysisWireOrder are the ones I had in mind: https://www.opencascade.com/doc/occt-7.0.0/refman/html/class_shape_analysis___wire.html These would fix the problem if it is related to edge ordering. I am not sure they would fix the issue if they are related to wire nesting issues, however. One other strategy might be to look at the FreeCAD code and see what they do when you extrude a drawing. I suspect that this case would work fine if the objects were imported into a sketch and then the sketch was extrude, so they solve it somehow.... |
Here is a starting point to get into what's going on in OCC land: https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Part/App/FeatureExtrusion.cpp In this code you can begin to see the limitations of using OCC. Note on this line how FreeCAD folks have applied a work around to use a copy to work around a problem extruding circles: https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Part/App/FeatureExtrusion.cpp#L260 It looks like they have a dedicated class to make an extrudable face out of wires: https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Part/App/FeatureExtrusion.cpp#L304 https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Part/App/FaceMaker.cpp |
Hmm... looks like quite the rabbit hole :) I learned something else, recently while trying your suggestion to change the order of edges. If I reverse the edge list order, nothing changes and the issue still occurs. What is still strange to me, though, is that the other 4 internal wires (at the corners) worked without switching start/end vertices. And I checked if the start of one edge aligns with the end of the other. They all do, by default. So, I cannot simply compare one edge's start to the next edge's end, as that doesn't necessarily indicate that 'flipping' the edge is necessary. |
@adam-urbanczyk I'm not sure exactly what you'd like? Is there a brep export directly in CQ, or do you want me to save the STEP files from Solidworks out to their wireframe modes? I recently pushed some changes to the dxf_branch. I appear to have broken some things, unfortunately (still new to most of this stuff). After cloning to my VPS and fiddling a bit, I was able to get the current dxf function to work as expected. Essentially I do a check for clockwise or counter clockwise orientations of the edges, and then force all to be CCW. This has so far proven to work for all of the dxf files I've tried. There's still a good chance this isn't perfect, though. |
@adam-urbanczyk do you want a bunch more DXFs to try? And, what are your thoughts about how we can bundle common profiles with CQ? I have this huge library of standard ANSI sections ( steel tubes, i beams, etc). Seems a shame not to bundle them all into CQ with a cool function that will generate those sections automatically by name But then again maybe that's best done as a separate module ( plugin ) |
I know you asked the other Adam... but I hope I can still answer too :) I think the dxf import makes sense as part of the CQ core functionality. Regardless of that, it might be useful to have them all for testing purposes on my end. Could you help me out with that, @dcowden ? |
Sorry about that-- I meant you but input from all Adams is great. Tonight i'll make a big zipfile of them all and post them somewhere for you. |
may I have those too? 😄 |
@easyw sure thing! |
@easyw @adam-urbanczyk @RustyVermeer @jmwright |
Would your idea be as simple as creating a github repo full of dxf files and calling it a day? |
@RustyVermeer @easyw @adam-urbanczyk @jmwright |
@RustyVermeer You can import/export a .brep file using CQ (both in FreeCAD and OCC backends), which is an OCC-specific lossless format. That is what I meant. @dcowden Yeah would be nice to have those bundled with CQ. BTW: do you know https://github.com/jreinhardt/BOLTS ? |
This has been closed in favor of the CQ 2.0 implemention at https://github.com/cadquery/cadquery |
Created from issue #155
The text was updated successfully, but these errors were encountered: