Add component from eCatalog


I want to add a component from the eCatalog to the world layout by using the .NET Api.

Can anyone give me a hint how to implement this function?

Thank you.

You can add reference to VisualComponents.eCatalogue.DataModel.dll and then do something like this. I didn’t test it so handling details such as file paths etc. might be wrong.

using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Linq;
using VisualComponents.Create3D;
using VisualComponents.eCatalogue.DataModel.Data;
using VisualComponents.eCatalogue.DataModel.Data.Entities;

namespace ECatAdder
    class ECatAdderTest
        private List<Item> eCatComponentCache;

        public ISimComponent AddComponent(IApplication app, string componentVCID)

            if (eCatComponentCache == null)
                eCatComponentCache = EnumerateECatComponents();

            var eCatItem = eCatComponentCache.FirstOrDefault(i => i.VCID == componentVCID && i.IsLocalItem);
            if (eCatItem == null) throw new ArgumentException("Unknown VCID");

            ISimComponent[] loadedComponents = app.LoadLayout(new Uri(eCatItem.FileUri));
            return loadedComponents.FirstOrDefault();


        /// <summary>
        /// Queries the local eCatalog SQL database for all components.
        /// </summary>
        /// <returns></returns>
        private List<Item> EnumerateECatComponents()
            var eCatContext = IoC.Get<IECatDataContext>();
            var eCatItems = eCatContext.EnabledItems;

            // Need to get all to a list first so Entity Framework doesn't try to convert the Where clause to SQL.
            return eCatItems.ToList()
                            .Where(i => !i.IsDeprecated && i.ModelType == "Component")




It works!

Thanks alot for your support!

Excuse me, how to use this code, for example, I want to write a form with c#. The form has an input box and a button. Enter the component ID in the input box and click the button to generate the component in the 3D world. How do I do this? Please advise, thank you.

How can I use this program? I want to create a form with c#, enter the name of the component in the input box, click the OK button, and the component will generate the coordinates I want to set in the 3D world.

Hello, I want to write a form with c#, the form has a button and an input box, enter the component name in the input box, click the button, the components in the component library will be generated in the 3D world, how to use this code?Please enlighten me.

Well, my example class is quite trivial to use so I assume your problem is with how to add such a form to the application in general and get a handle to IApplication instance.
For that take a look at the .NET API tutorials:

Haha, thank you. The problem has been solved. As you said, there is no handle for getting IApplication instances.