tag:support.nodebox.net,2012-11-01:/discussions/show-your-work/203-path_string-nodeNodeBox: Discussion 2017-06-30T07:23:08Ztag:support.nodebox.net,2012-11-01:Comment/427927762017-06-18T00:46:10Z2017-06-18T00:57:40Zpath_string node<div><p>Attached is a custom node: path_string. It converts a path to SVG notation. I have also provided a subnetwork, path_table, that converts that path string into a table of points with attributes (contour number and point type).</p>
<p>NodeBox paths consist of both line segments and curves, but information about the curves is hidden. You can see the difference by checking the Points checkbox above the canvas: blue dots are normal points, red dots are curve control points. If you convert a path to points, all you get are the normal points.</p>
<p>Nodebox also fails to provide a way of separating paths into distinct contours. When morphing or resampling text paths you get an unwanted line connecting the insides of multi-contour letters with their outsides.</p>
<p>Path_string and path_table provide a way around both of these limitations. By filtering the path table you can extract clean contours, and by accessing point types (P for normal point, C for control point) you can finally see (and potentially manipulate) what's been hidden.</p>
<p>The demo network shows how path_string illuminates three example shapes: a text path ("ab"), a quad curve, and an arc.</p>
<p>The first screenshot shows the output of the path_table subnetwork, in this case showing some of the "ab" points. The other three screenshots show the three sample shapes with normal points shown as blue dots and control points shown as red dots.</p>
<p>It's fun to adjust the T and Distance parameters of the quad curve, or the degrees of the arc to see how the control points change.</p>
<p>Now that we can see and work with curves and contours, my goal is to provide a way of reversing the process: turn strings back into paths. This would make it possible to precisely morph curves, draw a whole new class of curves with asymmetric control points, and who knows what else. Thanks to Frederik for pointing me to the location of the RenderPathData function.</p></div>johntag:support.nodebox.net,2012-11-01:Comment/427927762017-06-19T09:31:31Z2017-06-26T03:37:09Zpath_string node<div><p>A correction and some new tricks...</p>
<p>I said Nodebox hides the information about curves. This is not entirely true. When you convert a path to points, you do get all the points (including the control points). I meant that Nodebox hides which points are which.</p>
<p>But it turns out there is a way to make Nodebox reveal this secret. The trick is to do a lookup on "type". If you do this to a list of points you will see 1, 2, or 3 for each point.</p>
<p>1 = LINE_TO (normal point)<br>
2 = CURVE_TO (normal point at end of curve)<br>
3 = CURVE_DATA (control point)</p>
<p>Using this trick, you could compute the type column in my path_table without having to convert the path to an SVG path string.</p>
<p>I also said that NodeBox fails to provide a way of separating paths into distinct contours. It doesn't provide a node to do this, but after some experimentation, I did find a way of doing this using ordinary nodes.</p>
<p>The trick is the Resample node, the only node that acknowledges the existence of contours. If you give this node a path with multiple contours, set method to "By amount" and points to 1, then check "Per Contour", you will get the starting point of each contour. You can then locate the first occurrence of each starting point and use that information to slice the path into individual contours.</p>
<p>I demonstrate this technique here:</p>
<p><a href="http://support.nodebox.net/discussions/show-your-work/205-replace-insides">http://support.nodebox.net/discussions/show-your-work/205-replace-i...</a></p>
<p>I realize this is very arcane. But insights like this can help you gain full control over NodeBox paths.</p></div>johntag:support.nodebox.net,2012-11-01:Comment/427927762017-06-22T07:49:22Z2017-06-26T03:39:36Zpath_string node<div><p>One more update and another gift...</p>
<p>I just used the path_string node to solve a problem I encountered at work. I needed to import an SVG file into NodeBox of a flowchart made of boxes, ellipses, straight lines, curved lines, and arrows. When NodeBox reads in an SVG it sometimes looses the fill and stroke colors, forcing you to colorize them yourself.</p>
<p>Each of these objects have to be colorized in a different way, so in order to reconstruct the SVG I had to be able to tell the objects apart. I had been using point count, but I discovered that some curves had the same number of points as the ellipses. So how could I tell them apart?</p>
<p>The most obvious difference is that curves are open and ellipses are closed. So how could I tell if a given path was open or closed? Doing a lookup on the closed property doesn't work.</p>
<p>path_string to the rescue! The SVG path string of a path contains a "Z" for each closed contour. So all I had to do was feed each path into path_string and feed that string into a simple subnetwork I wrote to detect the presence of a "Z". Problem solved.</p>
<p>Demo with "is_closed" subnetwork attached. Enjoy!</p></div>johntag:support.nodebox.net,2012-11-01:Comment/427927762017-06-29T09:18:42Z2017-06-29T09:18:42Zpath_string node<div><p>Wow, this is great! The SVG import trick really sounds like "hacks upon hacks", we should figure out a better way to retain more information on the path...</p></div>Frederik De Blesertag:support.nodebox.net,2012-11-01:Comment/427927762017-06-29T10:07:46Z2017-06-29T10:07:46Zpath_string node<div><p>I agree: mucking with SVG notation departs from the true spirit of NodeBox which is to liberate right-brained artists from the tedium of cryptic code stuff.</p>
<p>The goal should be to give the artist full control over paths. It should be easy to pull multiple contours out of a path, tell curves from lines, see if contours are closed and be able to close or open them, etc.</p>
<p>NodeBox should also provide the ability to make curves with arbitrary control points, not just the pre-determined control points of arcs and quads. I have already made a custom curve node to do this, but am still looking for something interesting to do with it. I found an open source algorithm for finding control points which follow a sequence of points but have not yet found the time to adapt it.</p>
<p>I was hoping that if you could make your release process more automatic we would see the improvements to CSV export you promised and then a whole cascade of other long-requested features. How is that coming?</p></div>johntag:support.nodebox.net,2012-11-01:Comment/427927762017-06-29T10:41:01Z2017-06-29T10:41:01Zpath_string node<div><p>The process is certainly automated now, which does make it easier to make releases.</p>
<p>However I've been caught up in end-of-academic year meetings and discussions.</p>
<p>I'll try to make a release with the latest CSV updates before I leave on holiday next week.</p></div>Frederik De Blesertag:support.nodebox.net,2012-11-01:Comment/427927762017-06-29T15:48:04Z2017-06-29T15:48:04Zpath_string node<div><p>Latest release is here:</p>
<p><a href="https://github.com/nodebox/nodebox/releases/tag/v3.0.48">https://github.com/nodebox/nodebox/releases/tag/v3.0.48</a></p></div>Frederik De Blesertag:support.nodebox.net,2012-11-01:Comment/427927762017-06-29T22:25:34Z2017-06-29T22:25:34Zpath_string node<div><p>Thanks, Frederik!</p>
<p>Installed on my Mac and it works perfectly:</p>
<ul>
<li>default comma means I can just double-click to open in Excel</li>
<li>opting out of quotes means my Graphviz file opened perfectly</li>
<li>column order is no longer scrambled</li>
</ul>
<p>However, when I tried downloading the .EXE on my work PC and launching the installer from the desktop, I got a cascade of errors:</p>
<p>Failed to find library,<br>
C:<my_domain>\AppData\Local\NodeBox\runtime\bin\client\jvm.dll</p>
<p>Failed to locate JNI_CreateJavaVM</p>
<p>Failed to launch JVM</p>
<p>I tried uninstalling, rebooting, to no avail. During the install process I think I saw it saying it was installing jvm.dll, but when I look in runtime\bin\client it is not there - or anywhere else on my machine.</p>
<p>At that point, NodeBox was completely hosed on my PC. But I had an old 3.46 exe file and running that restored the older version. There is still no jam.dll file on my machine.</p>
<p>Perhaps some other PC user can verify. But for me, the PC install did not work.</p>
<p>John</p></div>johntag:support.nodebox.net,2012-11-01:Comment/427927762017-06-29T22:51:58Z2017-06-29T22:52:55Zpath_string node<div><p>Update:</p>
<p>I tried uninstalling Java on my PC, reinstalling Java, then reinstalling NodeBox 3.0.48. No change. Still failed to find the jvm.dll. Once I reinstalled 3.0.46 I was able to run the older version again.</p></div>johntag:support.nodebox.net,2012-11-01:Comment/427927762017-06-30T01:36:48Z2017-06-30T01:36:48Zpath_string node<div><p>this time it just worked fine for me, but I remember after uninstalling you had to delete the C:\Users\X\AppData\Local\NodeBox folder also, at least at some moment, check this thread: <a href="http://support.nodebox.net/discussions/general-discussion/14713-cant-start-nodebox-3045">http://support.nodebox.net/discussions/general-discussion/14713-can...</a></p></div>riochtag:support.nodebox.net,2012-11-01:Comment/427927762017-06-30T02:00:54Z2017-06-30T02:03:18Zpath_string node<div><p>Rioch,</p>
<p>That did the trick! I deleted the NodeBox folder, re-ran the installer, and now 3.0.48 works fine on my PC. I celebrated by hooking seven strings to a concatenate node.</p>
<p>Thanks. And thanks again, Frederik.</p>
<p>John</p></div>johntag:support.nodebox.net,2012-11-01:Comment/427927762017-06-30T07:23:04Z2017-06-30T07:23:04Zpath_string node<div><p>Hmm, I should find a way to fix this so installs are always "clean" installs.</p></div>Frederik De Bleser