Add dynamic Components

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

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

Then resetting should delete the instance.

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:

ISimComponent clonedPart = (ISimComponent)part.Clone(CloningMode.Unique, false);
IComponentContainer componentContainer = (IComponentContainer)robotController.InitialTool.Node.Behaviors.FirstOrDefault();
componentContainer.Grab(clonedPart);

Thx & Regards

Feature

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.

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…

 

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. :slight_smile:

Thx & Regards

Feature