Is it possible to import DrawBot as a module into NodeBox3?

gor's Avatar

gor

02 Mar, 2019 11:59 PM

I am wondering if it is possible to import DrawBot as a module into NodeBox3, and be able you use its syntax (which looks to be similar to how NodeBox1 works) with the power of visually connecting nodes?

DrawBot
http://www.drawbot.com

  1. Support Staff 1 Posted by john on 03 Mar, 2019 02:15 AM

    john's Avatar

    Gor,

    Another interesting question!

    I was not familiar with DrawBot. But my first reaction after checking it out is that NodeBox IS Drawbot. The two overlap heavily and seem largely redundant.

    NodeBox 1 was (and still is) a way to let you draw more easily in Python with the same primitives DrawBot supplies plus many more. NodeBox 3 makes it even easier turn code into drawings - and can still support Python code directly using custom nodes. NodeBox 3 already lets you harness a similar syntax "with the power of visually connecting nodes".

    So I'm curious: if you could import DrawBot into Nodebox (and I think you could to a large extent using custom nodes that reference the DrawBot library) - what would you do with it that you can't already do with NodeBox?

    John

  2. 2 Posted by gor on 03 Mar, 2019 04:28 AM

    gor's Avatar

    As I mentioned in my other post, I am new to NodeBox (I actually happily discovered it just yesterday), so the question may be a bit naive. I guess the reason for importing DrawBot would be to access the syntax that I've become familiar with and even hope to take bits of code and be able to divide them up into node components and rewire them.

    Take for example Formatted String in DrawBot which essentially give full access to essentially all the properties for formatting texts (font size, line height, opentype features, font variations, etc. ) –  http://www.drawbot.com/content/text/formattedString.html

    I imagine it would be possible to create a sort of ultimate text node that would allow you to simply plug-in any of these properties and control them with other nodes.

    Would the way to go about importing DrawBot to be similar to the Writing Your Own Nodes tutorial? As a simple test, I've tried creating a custom node that tries to reference a .py file that only contains 'import drawBot' but I am not quite sure if I am referencing it correctly...what should go in the output field and function (core/zero) field? Loading the code, I receive errors 'ImportError: No module named drawBot'.

    I would appreciate any guidance to help get me started.

    –Gor

  3. Support Staff 3 Posted by john on 03 Mar, 2019 06:17 AM

    john's Avatar

    Yes, writing custom nodes is the normal way for NodeBoxers to import other Python code.

    I'm not the best one to ask on this, though. My Python skills are rusty. I have managed to create a half-dozen Python-based custom nodes, but I am far from a master at that art - and there is very little documentation. I try to do everything in NodeBox and only resort to custom nodes as a last resort.

    To get access to other libraries you have to include an "import from" statement at the top of your code, and the libraries have to be installed somewhere. So far I've stuck with basic core libraries and some NodeBox libraries that part of the build. Another option would be to simply copy paste chunks of open source code directly into your custom nodes.

    NodeBox 3 is actually built on something called Jython which allows it to access earlier code written in Java. It requires an older version of Python (2.8?) so Python 3 code may break.

    You can find various custom nodes in the forum and download them to see how they work. I still find it confusing. Here is a discussion about a recent node I made that takes in a list of points and returns a convex hull (the subset of points that form a convex envelope around the point set):

    http://support.nodebox.net/discussions/nodebox-2-3/5985-how-do-i-pass-points-to-and-from-a-custom-node

    You can study that one to see how it works.

    The formattedString link you sent was quite interesting. But as I mentioned in my other note, NodeBox, incredibly enough, does not have a text object. Everything is done with vector paths. You could create a custom node that would let you set some of the properties in that link, but in order to play well with the rest of NodeBox, your node would have to actually render the font and return a path, not a text object. In other words, you might be able to construct a fancier version of the textpath node. A non-trivial task, but if you could pull it off there might be parades in your honor.

    John

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

16 Feb, 2025 11:13 AM
15 Feb, 2025 12:51 PM
06 Feb, 2025 01:37 AM
04 Feb, 2025 06:32 AM
04 Feb, 2025 05:04 AM

 

30 Jan, 2025 09:31 AM
30 Jan, 2025 09:08 AM
30 Jan, 2025 08:40 AM
24 Jan, 2025 07:50 AM
22 Jan, 2025 11:42 PM
21 Jan, 2025 09:43 AM