How to get the type of an item

Jussi Jokinen's Avatar

Jussi Jokinen

06 Jul, 2023 12:04 PM

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

  1. Support Staff 1 Posted by john on 06 Jul, 2023 09:19 PM

    john's Avatar

    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

  2. 2 Posted by Jussi Jokinen on 07 Jul, 2023 06:26 AM

    Jussi Jokinen's Avatar

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

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 Mar, 2025 11:04 PM
14 Mar, 2025 08:32 AM
10 Mar, 2025 06:36 PM
10 Mar, 2025 06:36 PM
10 Mar, 2025 06:36 PM

 

10 Mar, 2025 12:30 AM
02 Mar, 2025 12:34 AM
01 Mar, 2025 12:27 AM
24 Feb, 2025 11:24 PM
24 Feb, 2025 08:19 AM
24 Feb, 2025 01:07 AM