Add dynamic Components

Forum Forums Visual Components 4.1 .NET Addon Programming Add dynamic Components

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

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #18555
    Avatar
    CaptainFeature
    Participant

    Hello,

    is there a way to add dynamic components to a running simulation via .net.

    I try to clone a component and would mark it as dynamic, so if the simulation getting reseted the component should disappear.

    Thx & Regards

    Feature

    0
    #18629
    Avatar
    jouha
    Moderator

    Grab the cloned component to any container (e.g. a Path or ComponentContainer).

    Then resetting should delete the instance.

    0
    #18631
    Avatar
    CaptainFeature
    Participant

    Hy jouha,

    Then resetting should delete the instance.

    I think thats not happening, the component stays in the FeatureTree and I have to delete it manually.

    I do following:

    Thx & Regards

    Feature

    0
    #18635
    TSy
    TSy
    Participant

    The .NET API isn’t really meant for runtime logic, only configuration and UI so you’ll save yourself from a bunch of trouble by doing things like this with Python scripts instead.

    Note that if you must, you can create (static) components, including Python script behavior content from the .NET API, but the scripts can’t be compiled when simulation is running.

    0
    #18658
    Avatar
    jouha
    Moderator

    Python is definitely the most efficient and convenient tool for this type of thing.

    Seems that the .NET differs from Python here. It’s making cloned component dynamic only if the template (source) component is already dynamic. CreateComponent is creating only static ones. So, it seems like a dead-end with .NET unless you do it manually by using e.g. the ISimulation. SimulationReset event to delete your component instances etc.

    Harmonizing the logic with Python would be great here…

     

    0
    #18662
    Avatar
    CaptainFeature
    Participant

    Hy TSy and jouha,

    thx for reply.

    […] SimulationReset event to delete your component instances etc.

    Harmonizing the logic with Python would be great here…

    I solved it already by delete the components as you recomended!

    Harmony is always worthwhile. 🙂

    Thx & Regards

    Feature

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

You must be logged in to reply to this topic.