The new NodeBox forum is live! Everything from support.nodebox.net moved here: sign in with the same email to pick up your old posts. Something not working? Write to forum-support@nodebox.net.

NodeBox 3From the old forum

How to get the type of an item

2 replies Last reply

  1. Hi!

    A wall I've been banging my head against:
    I'd like to make a table cell node that renders a simple cell with certain dimensions and content. I'd like to make it accept both paths and strings as content. It would be easy if I'd only could get the type of an list item that I'm feeding to the cell node. If the type of input would be path, I'd just pass it forward but if type would be string, I'd render it with textPath node first.

    I can think of workarounds, but I'd guess someone else has bumped into same problem before...

    Best,
    Jussi

    Copy link
  2. Jussi,

    Rejoice! There is indeed a simple (if undocumented) solution to this problem.

    Use a lookup node, and for the key enter "class.simpleName".

    You will get one of seven possible strings in response:

    • Point for a point
    • Path for any other shape (line, ellipse, rect, etc.)
    • Geometry for a group
    • String for a string
    • Color for a color
    • Double for a floating point number
    • Long for an integer

    I think that's all the possibilities. I figured this out using the key node. The key node tells you the properties available for any Nodebox object. You can then do a lookup on one of those properties (e.g. class) and feed THAT into a key node to find out what dot (sub) properties are available.

    Happy Nodeboxing!

    John

    Copy link
  3. Thank you so much, John!
    I should've thought of keys… :D

    Copy link

Know something that helps?

Sign in with your email address to reply. No password needed.

Sign in to reply