How to bind an object to a node?

Forum Forums Visual Components 4.1 .NET Addon Programming How to bind an object to a node?

This topic contains 5 replies, has 3 voices, and was last updated by febjc0 febjc0 5 months, 1 week ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #14184
    febjc0
    febjc0
    Participant

    Hi,

     

    I created a custom component with the .net addon and I’d like to bind some additional objects to each node of it. Is there any way to do that?

    #14190
    Keke
    Keke
    Moderator

    Hi,

    To attach components to a parent node you can use ISimNode.AttachTo() method. So this snippet would attach comp2 to comp1:

    -k

    #14194
    febjc0
    febjc0
    Participant

    Hi Keke,

    Thanks for replying. But what I want is to add some data to a node.

    for example:

    #14197
    Keke
    Keke
    Moderator

    Well there are many ways you could store data in a node. You could use for example a property or a note behaviour. Note behaviour might be more suitable for large strings. Here’s a small snippet to create a string property and a note behaviour:

    To access existing properies and note behaviours use ISimComponent.GetProperty() and ISimComponent.FindBehaviour() methods. IBehavior needs to be cast to INote type for accessing its contents on (INote.Note).

    -k

    #14231
    ccamilo
    ccamilo
    Participant

    Another way, if there is no need for data persistancy, is by using IApplication.SetSessionValue() method. In there you can store any object like, for example, a Dictionary which you can use to link some data to an ISimNode

    #14240
    febjc0
    febjc0
    Participant

    Thanks Keke & ccamilo, your answers are really helpful.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.