SVG file throwing nullPointerException

I was given some svg files by a colleague for incorporating a project I’m working on, but it’s throwing a nullPointerException error (Actuator.svg). snowman.svg is loading fine.

Actuator was cause a style error, but I found what they needed to do to fix that error with Adobe Illustrator. This problem I can’t locate a fix for. Any thoughts? Thanks.

  try {
    s = loadShape("Actuator.svg");
  } catch (Exception e) {
    e.printStackTrace();
    s = loadShape("snowman.svg");
  }
1 Like

When you use try early during developing a Sketch you hinder processing to throw a proper error message

Try without try

It throws a nullPointerException as noted. That’s why I put the try in to catch and try another Svg that works.

1 Like

So any other thoughts?

I don’t understand what this means. It was causing an error, but they fixed it, but they didn’t?

The SVG file spec is massive. loadShape only has limited support for it. Your SVG could contain any one of dozens of things that loadShape doesn’t support. You could try converting it to a rastor format, resaving it using SVG1.1 to force down the feature set, sharing the actual details of your error on this thread, and / or just hacking away parts of your svg until it starts working to narrow down the problem. Unfortunately there is no one reason why SVGs fail.

See also: Get new size of PShape after transform (shear)? - #2 by snaders

Ok, thank you, that helps me understand the issues.

Good luck – hope you find a fix / workaround. If you have a specific file or log to share perhaps the forum can be of more help.