Skip to content
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

The view angle for SVG export is not ideal #82

Closed
shimwell opened this issue Jul 16, 2020 · 6 comments
Closed

The view angle for SVG export is not ideal #82

shimwell opened this issue Jul 16, 2020 · 6 comments

Comments

@shimwell
Copy link
Collaborator

shimwell commented Jul 16, 2020

The viewing angle of the SVG export in CADquery has currently hard coded viewing angle which is not perfect for the Paramak as it is from above.

Here is the default view
reactdefault

If you open up the exporter.py file in you source code for your local install of CADquery mine is saved in '/home/jshim/anaconda3/lib/python3.7/site-packages/cadquery/occ_impl/exporters.py or sometimes in /home/jshim/cadquery/cadquery/occ_impl/exporters.py' then you can change the default hard coded angle

From this
DEFAULT_DIR = gp_Dir(-1.75, 1.1, 5)
To something like this
DEFAULT_DIR = gp_Dir(-2, 5, 1.1)

The result is an improved view angle for the SVG export :-)
react

This is a a temporary fix as CADQuery will probably support viewing angle as an argument in export_svg in the future and there is an open issue for this CadQuery/cadquery#246

@shimwell
Copy link
Collaborator Author

Looks like the line intensity is not changed to the new so perhaps not a good fix, worth a try

@shimwell
Copy link
Collaborator Author

shimwell commented Jul 16, 2020

also the x,y,z axis can be removed if this code is removed from the end if the exporters.py file

        <line x1="30" y1="-30" x2="75" y2="-33" stroke-width="3" stroke="#000000" />
         <text x="80" y="-30" style="stroke:#000000">X </text>

        <line x1="30" y1="-30" x2="30" y2="-75" stroke-width="3" stroke="#000000" />
         <text x="25" y="-85" style="stroke:#000000">Y </text>

        <line x1="30" y1="-30" x2="58" y2="-15" stroke-width="3" stroke="#000000" />
         <text x="65" y="-5" style="stroke:#000000">Z </text>
        <!--
            <line x1="0" y1="0" x2="%(unitScale)s" y2="0" stroke-width="3" />
            <text x="0" y="20" style="stroke:#000000">1  %(uom)s </text>
        -->
    </g>

react

@shimwell
Copy link
Collaborator Author

shimwell commented Jul 29, 2020

my_reactor.solid.rotate(startVector=(0,1,0), endVector=(0,0,1), angleDegrees=180)
my_reactor.export_svg('rotated_with_correct_solid_lines.svg')
Thanks for the suggestion @billingsley-john

@shimwell
Copy link
Collaborator Author

shimwell commented Nov 16, 2020

Perhaps something like this should be put into the Reactor.export_svg() method

from cadquery import exporters
with open('rrr.svg', "w") as f:
    exporters.exportShape(my_reactor.solid.rotate(startVector=(0,0,1), endVector=(0,1,0), angleDegrees=180), "SVG", f)

@shimwell
Copy link
Collaborator Author

Looks like some new SVG feature on CadQuery will allow all sorts of great SVG export options CadQuery/cadquery#596

@shimwell
Copy link
Collaborator Author

There are some new features arriving in CQ 2.1 for this https://github.com/CadQuery/cadquery/pull/596/files

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,
                 "out2.svg")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant