Delete and identify components via .NET Add Ons

Hi everyone,
I want to create a list of all in the simulation created materials, that are stil within the simulation.
In a video I got the hint to use “app.World.Components.Where(c => c.IsDynamic == true).Select(c => c.Material).ToList();”
That works as it is intendet to, I think. I returns a “System.Collections.Generic.List`1[VisualComponents.Create3D.IMaterial]”.
Can I get an unique identifier out of this? If yes, how?

Also, using that unique identifier, can I delete a specific part, without deleting the other parts of the same kind?

I am still new to VC, so excuse me please if that question might seem easy to answer.
Thanks a lot!

If you want to find out materials (i.e. IMaterial objects) created during simulation I think that approach won’t give you accurate results as materials can be applied not only to components directly, but to individual nodes and features (geometries) etc.

A better approach could be to get list of all materials when simulation starts (IApplication.Materials) and then comparing that to current state.

Anyway, I didn’t quite understand what you are trying to delete. All components with a specified material type? It would be better to use a component property for that I think.

Thanks for the reply!
I want so create a list of all components, that a feeder or similar created.In another application, the user can view them and, if necessary, delete them from the application.
Therefor I need an unique identifier for that parts, so not all parts of the same material, only one of them.
Is there such an identifier in VC? And if yes, how can I access it?
And is there away to delete one specific part, in best case, using that unique identifier?

Within VC you can use the ISimComponent objects themselves directly, and within same session you could use the IWrapper.Pointer to get memory address of the underlying component object, which will be unique and serializable.

OK, thank you!
I have an object of ISimComponent now.
Is there a way to delete that from the simulation? I want it to be gone for good, not just invisible.
Can I call a function or set a variable zu a specific value?
Thanks!

Just use ISimWorld.DeleteComponent(…), or even ISimComponent.RootNode.Delete()

1 Like