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

4 comments
  • Hi,

    I want to change the color of individual entities based on source.

    However, Draw(...) is not accessible.

     

    Eyeshot Version = 11.0.713.0

    protected override void

    Draw<T, Q>(ViewportLayout.DrawEntitiesParams<T, Q> myParams, ViewportLayout.drawCallback<T, Q> drawCall)

    {

         ...

    }

     

     

  • Hi,

    you just need to update the overridden method with the new signature (let visual studio do it for you)

     

    protected override void Draw<T>(T myParams, ViewportLayout.drawCallback<T> drawCall)
    {
         ...
    }

  • I changed the color by referring to the void Draw <T> code.
    I did not get the desired result.

    Objects belonging to individual blocks, not entire blocks
    Can I change the color?

     

    - Code : 

    var block = new devDept.Eyeshot.Block();
    var s1 = devDept.Eyeshot.Entities.Mesh.CreateSphere(10, 10, 10);
    s1.Color = Color.Red;
    s1.ColorMethod = devDept.Eyeshot.Entities.colorMethodType.byEntity;

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

    block.Entities.Add(s1);
    block.Entities.Add(s2);
    viewportLayout1.Blocks.Add("myBlock", block);

    //
    var br1 = new ColorBlockReference(new devDept.Eyeshot.Entities.BlockReference(10, 10, 10, "myBlock", 0), 0, Color.Green);
    var br2 = new ColorBlockReference(new devDept.Eyeshot.Entities.BlockReference(10, 50, 10, "myBlock", 0), 1, Color.Orange);
    var br3 = new devDept.Eyeshot.Entities.BlockReference(10, 100, 10, "myBlock", 0);

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

    viewportLayout1.Entities.Add(br1);
    viewportLayout1.Entities.Add(br2);
    viewportLayout1.Entities.Add(br3);

    viewportLayout1.ZoomFit();
    viewportLayout1.Invalidate();

     

    public class ColorBlockReference : BlockReference
    {

        public int EntityIndex;
        public System.Drawing.Color EntityColor;

        public ColorBlockReference(BlockReference another, int entityIndex, System.Drawing.Color entityColor)
            : base(another)
        {
            this.EntityIndex = entityIndex;
            this.EntityColor = entityColor;
        }

        protected override void Draw<T>(T myParams, ViewportLayout.drawCallback<T> drawCall)
        {
            myParams.GfxParams.Blocks[BlockName].Entities[this.EntityIndex].Color = this.EntityColor;
            base.Draw(myParams, drawCall);
        }

    }

     

    - Result : 

     

    - Desired structure

  • Please open a support request as explained here: https://www.devdept.com/Support

Please sign in to leave a comment.