BlockReference that draws only some of the Block entities

Requires Eyeshot >= 9.0.374.

Derive the BlockReference class so that it sets the visibility of the unwanted entities of the Block to false before drawing them: 

        class MyBR : BlockReference
        {
            public int EntityToHide;
            public MyBR(BlockReference another, int entityToHide) : base(another)
            {
                EntityToHide = entityToHide;
            }

            protected override void Draw<T, Q>(ViewportLayout.DrawEntitiesParams<T, Q> myParams, ViewportLayout.drawCallback<T, Q> drawCall)
            {
                myParams.GfxParams.Blocks[BlockName].Entities[EntityToHide].Visible = false;
                base.Draw(myParams, drawCall);
                myParams.GfxParams.Blocks[BlockName].Entities[EntityToHide].Visible = true;
            }
        }   

 

And use it like this: 

        private static void CreateBlockRef(ViewportLayout vp)
        {
            var block = new Block();
            var s1 = Mesh.CreateSphere(10, 10, 10);
            s1.Color = Color.Red;
            s1.ColorMethod  = colorMethodType.byEntity;

            var s2 = (Entity)s1.Clone();
            s2.Translate( 20, 0, 0);
            s2.Color = Color.Blue;

            block.Entities.Add(s1);
            block.Entities.Add(s2);

            vp.Blocks.Add("myBlock", block);

            var br1 = new MyBR(new BlockReference(10, 10, 10, "myBlock", 0), 0);
            var br2 = new MyBR(new BlockReference(10, 50, 10, "myBlock", 0), 1);
            var br3 = new BlockReference(10, 100, 10, "myBlock", 0);

            br1.Attributes.Add("1", new AttributeReference(0, 10, 0, "br1: hides the first entity", 5));
            br2.Attributes.Add("1", new AttributeReference(0, 10, 0, "br2: hides the second entity", 5));
            br3.Attributes.Add("1", new AttributeReference(0, 10, 0, "br3: standard BlockReference", 5));

            vp.Entities.Add(br1);
            vp.Entities.Add(br2);
            vp.Entities.Add(br3);
        }

 

The br1 hides the first entity of the block, the br2 hides the second entity, the br3 is a standard BlockReference and draws both entities:

 

 

 

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.