-
Notifications
You must be signed in to change notification settings - Fork 295
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
Expose SVG Export Options and Add Some Useful Extras #596
Conversation
It looks like you're planning to add an option to display the axis indicators? |
I'm actually thinking of taking the axis indicator out because it's too hard to draw it dynamically for each possible projection direction. I'm not sure how much value it adds either. |
We could use CQ to render the indicator, say a cube with embossed +-XYZ text on appropriate faces. But maybe that is something for a separate PR and definitely should be optional. Another thing I realized recently - maybe it'd be good to make hidden dashed line optional. For complex models they add quite some visual noise: |
Looks good!
These are actually the ones that I found myself editing to preview the SVGs in the browser. |
Thanks for the feedback everyone.
I'll add a deprecation warning. I definitely think we can do something better with that indicator in the future. I'm wondering if for now I just go ahead and add an option to show/hide the axes indicator and make it so that it only works with the default direction, and then note that in the docstring. It will be a little confusing for now, but everything will fall into place when a new indicator is added later.
@adam-urbanczyk By "flat options" you mean keyword arguments, correct? @adam-urbanczyk @marcus7070 Am I understanding correctly that the dictionary |
Indeed, that is what I meant. Though after looking at the code I'm not so sure if I still have that opinion. Maybe let's park it for now. |
There's still work to do, but I think I've got all the options added unless there's a desire to have hidden line stroke-width set independently of the visible line stroke-width. The The axes indicator only works if you set import cadquery as cq
from cadquery import exporters
result = cq.Workplane("XY").box(10, 10, 10)#.circle(1.0)
exporters.export(result,
"/home/jwright/Downloads/out.svg",
opt={"width": 100,
"height": 100,
"marginLeft": 10,
"marginTop": 10,
"showAxes": False,
"projectionDir": (-1.75, 1.1, 5),
"strokeWidth": 0.25,
"strokeColor": (255, 0, 0),
"hiddenColor": (0, 0, 255),
"showHidden": True})
exporters.export(result,
"/home/jwright/Downloads/out2.svg") |
Co-authored-by: Marcus Boyd <50230945+marcus7070@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## master #596 +/- ##
==========================================
- Coverage 94.26% 94.25% -0.02%
==========================================
Files 29 29
Lines 6348 6366 +18
Branches 675 679 +4
==========================================
+ Hits 5984 6000 +16
- Misses 226 227 +1
- Partials 138 139 +1
Continue to review full report at Codecov.
|
@adam-urbanczyk codecov refuses to see that line 260 is covered, even though I can test it manually and it is hit. Please review at your convenience. If you don't find anything else, this should be ready to merge unless you want to wait until after the 2.1 release. |
I really wasn't paying enough attention. I copied the STL test and added the SVG options to it. I've fixed that now and hopefully everything will go green, including the lint error for line 260. |
Great, let's merge this before the final 2.1 . Just give me some time for the review. |
Looks good @jmwright , thanks! Shall I merge it? |
Yes, please do. |
I'm still working on this, but wanted to get it out in the open to get feedback.
Exposed the
getSVG()
'opt' parameter so that things like height, width and margins could be controlled. Also added a projection direction opt to control the projection view of the shape. The following code currently works with this fork/branch:There's been some discussion around SVGs and HLR lately, so feedback is welcome. I'll share on Discord to get feedback as well.
Tagging @adam-urbanczyk and @marcus7070