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

Not Indexing full svg path while making model fromSVGPathData #569

Open
Gautam2010 opened this issue Sep 1, 2023 · 4 comments
Open

Not Indexing full svg path while making model fromSVGPathData #569

Gautam2010 opened this issue Sep 1, 2023 · 4 comments

Comments

@Gautam2010
Copy link
Contributor

Gautam2010 commented Sep 1, 2023

Trying to make model with simple below svg path

M249.286 106.372L471.068 327.86 
H471.068 27.505 27.505 L249.286 106.37200000000001Z

This is the preview of svg path.
image

I am making model with bolow code.

const svgPath=`M249.286 106.372L471.068 327.86 
H471.068 27.505 27.505 L249.286 106.37200000000001Z`

const makerModel=makerjs.importer.fromSVGPathData(svgPath);

Due to some reason it is not indexing some of lines.

const svg=makerjs.exporter.toSVG(makerModel);

Response of final svg becomes like below
image

Final svg output
<svg width="221.782" height="221.488" viewBox="0 0 221.782 221.488" xmlns="http://www.w3.org/2000/svg"><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#000" stroke-width="0.25mm" fill="none" style="stroke:#000;stroke-width:0.25mm;fill:none"><path d="M 0 0 L 221.782 221.488 L 0 0 Z" vector-effect="non-scaling-stroke"/></g></svg>

It should give same output as input.

Code reproduced link

Tasks

No tasks being tracked yet.
@Gautam2010
Copy link
Contributor Author

@danmarshall
Is this something that MakerJs is designed to handle, or could it potentially be considered for inclusion in a future release?

Your insights would be greatly appreciated. Thank you!

@danmarshall
Copy link
Contributor

The parser code probably isn't robust enough to handle this case. PRs are welcome.

Meanwhile, if you check, then uncheck the "Minify output" button in the svg path inspector you can get a standardized output:

M 249.286 106.372 L 471.068 327.86 H 471.068 H 27.505 H 27.505 L 249.286 106.372 Z

@danmarshall
Copy link
Contributor

also, when using the path inspector, I noticed that this path data is somewhat degenerate - the repeated H commands (with the same value) do not move the position.

@Gautam2010
Copy link
Contributor Author

@danmarshall Thanks for your input.

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

2 participants