KnM 2d / SVG to LineStructure

franz's picture

Hi ! does ne1 have any example on how to convert a SVG file to a line structure ?

regards

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

gtoledo3's picture
Re: KnM 2d / SVG to LineStructure

The svg importer should provide a structure of paths. You should be able to use a structure index and key set to path right behind it, to return a single path, that you can then input to the Line Structure With Bezier path to return a line structure. I don't have a sample handy.

gtoledo3's picture
Re: KnM 2d / SVG to LineStructure

Here's an example.

The points will probably convert to QC coords that draw off screen, so you'll probably need to transform and scale to see them.

PreviewAttachmentSize
example.qtz2.55 KB

cybero's picture
Re: KnM 2d / SVG to LineStructure

I might be wrong, but although this example QuickLooks AOK in Lion, and even though within the Editor, when hovering one can find that the compositional construct you provided is functioning correctly, it does not render. I wouldn't be at all surprised to find that it does work as shown in Snow.

Like you say, due to the relatively large figures used, some recalculation / scaling of these is required.

The Kineme Line Structure patch does indeed output a Line Structure GL readable structure.

franz's picture
Re: KnM 2d / SVG to LineStructure

i see. thanks for the example ! I still need an iterator to render multiple paths. That's what I thought, I can't render a SVG straight to a LineStructure without iterator (if my SVG has multiple paths...)

... no I ended up building my own plugin to avoid iterating. (because my SVG contains only line segments so far)

franz's picture
Re: KnM 2d / SVG to LineStructure

SVG coords are in pixels, 0,0 being upper left corner. Some recalcultaions are needed tho', but the example illustrates perfectly the question.

thx both.

gtoledo3's picture
Re: KnM 2d / SVG to LineStructure

cybero wrote:
I might be wrong, but although this example QuickLooks AOK in Lion, and even though within the Editor, when hovering one can find that the compositional construct you provided is functioning correctly, it does not render. I wouldn't be at all surprised to find that it does work as shown in Snow.

Like you say, due to the relatively large figures used, some recalculation / scaling of these is required.

The Kineme Line Structure patch does indeed output a Line Structure GL readable structure.

Nah, not at all. Like I said, look at the coords of whatever you're loading, they're likely large numbers and rendering offscreen. I didn't include an SVG in the setup, if that's what you're looking for.

gtoledo3's picture
Re: KnM 2d / SVG to LineStructure

franz wrote:
i see. thanks for the example ! I still need an iterator to render multiple paths. That's what I thought, I can't render a SVG straight to a LineStructure without iterator (if my SVG has multiple paths...)

... no I ended up building my own plugin to avoid iterating. (because my SVG contains only line segments so far)

Yeah, or javascript. I would take the patch route too though.

cybero's picture
Re: KnM 2d / SVG to LineStructure

As it happens , I was using a .svg , really simple file, it was generating an appropriate structure from its path via the Kineme patch to the Line Structure GL patch.

The co-ords weren't rendering at all, not even in a scaled down 3D Transform.

Turns out the structure revealed when line hovering needed to be reduced to a 1/100oth of what it was intended to be. That was achieved using a 3D Transform.

I'm pleased to say that the attached example not only evidences the exemplar construct you posted, excepting it uses Index member , rather than Key, but also that it does work in Lion, which I kind of expected it would.

So spot on regarding the co-ords requiring recomputation.

PreviewAttachmentSize
kineme2dsvg.qtz4.45 KB
cross.svg_.zip741 bytes

cybero's picture
Re: KnM 2d / SVG to LineStructure

Here's a multiple line .svg composition, uses the .svg posted below. Will post here for click through convenience.

PreviewAttachmentSize
kineme2dsvgmultlines.qtz9.43 KB
cross.svg_.zip741 bytes

jersmi's picture
Re: KnM 2d / SVG to LineStructure

iterating kills fps here. wish there was a way to get lots (>100?) of "hand drawn" paths (that is, to be clear, paths with lots of points, like those made with a tablet or scanned, "organic" or "noisy" edges) up to reasonable fps.... here's my test patch with a quick tablet drawn svg (8 paths) animated inside an iterator.

franz wrote:
... no I ended up building my own plugin to avoid iterating. (because my SVG contains only line segments so far)
franz, do you mean the svg plugin you made a while back, or did you make a new one? just curious -- not that i would be so rude as to ask you to share.... :)

PreviewAttachmentSize
K2Dsvg.zip21.56 KB

franz's picture
Re: KnM 2d / SVG to LineStructure

yeah, i modifyied my SVG plugin to output a structure directly pipeable to KnM LineStructure. It will work with line segments only tho', so I doubt it will be of any use to other ppl. (it is intended to be used with our MAD_LAB line drawing application)

PreviewAttachmentSize
_1024_SVG_MAD.plugin.zip28.77 KB

jersmi's picture
Re: KnM 2d / SVG to LineStructure

thanks for sharing, franz.

franz's picture
Re: KnM 2d / SVG to LineStructure

you're welcome. here's an updated version that should work with paths as well, not just line elements (untested as I don't own Illustrator). The scaling is done internally from pixel to QC units, assuming the SVG size was 1024 by 768 pixels, and that the QC rendering ratio is 4:3 (2 QCunits by 1.5)

PreviewAttachmentSize
_1024_SVG_MAD.zip29.59 KB

jersmi's picture
Re: KnM 2d / SVG to LineStructure

okay, the scaling appears to work -- 1280x720 svg fits to height with origin locked to upper left, image extends off the right side.

so far the lines draw as i am used to seeing when set to line segments -- it skips every other line. this also connects path end points to next path (though not always?) nothing i try in illustrator makes a difference (svg save dialog, attributes panel). also tried google docs "drawing", no luck. hope you can work it out, looks promising.

PreviewAttachmentSize
eyeHand.svg_.zip18.13 KB
Screen shot 2011-08-08 at 6.25.28 PM.jpg
Screen shot 2011-08-08 at 6.25.28 PM.jpg55.42 KB