🌶️ Custom Entity with EntityGraphicsData

Starting from Eyeshot 2023 the EntityGraphicsData class is abstract. This article explains the recommended approach for creating an instance of the concrete class in a custom Entity. For a complete sample, you can see the SelectTriangle source code.

To create an instance you should override the Entity.InitGraphicsData() and use the RenderContextBase.CreateEntityGraphicsData() method. Be sure to check for null before creating the data, otherwise, they may be overwritten if the method is called more than once.

private EntityGraphicsData myData;

protected override void InitGraphicsData(RenderContextBase renderContext)

    if (myData == null) // initialize only once
        myData = renderContext.CreateEntityGraphicsData(this);

InitGraphicsData is called during the Entity compilation. When overriding the Compile() method, be sure to call the base or the InitGraphicsData first to initialize the data before using it.

public override void Compile(CompileParams data)
    base.Compile(data); // also calls the InitGraphicsData

    data.RenderContext.Compile(myData, MyDrawEntityCallBack, null);
Was this article helpful?
2 out of 2 found this helpful



Please sign in to leave a comment.

Articles in this section

See more