0

I have a custom class (MyBox) that extend devDept.Eyeshot.Entities.Solid and I want to add it to the ViewportLayout like this:

        MyBox box = new MyBox(10, 20, 30); // length, width, height

        EyeViewportLayout.Entities.Add(box);
        EyeViewportLayout.ZoomFit();
        EyeViewportLayout.Invalidate();

I notice that to visualize my class I need to call Solid.CreateBox(length, width, height) which return a new Solid. How can I do the same work of CreateBox inside my custom class MyBox so when I add it to ViewportLayout.Entities it get displayed ?

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
elia_c
  • 99
  • 1
  • 6

1 Answers1

0

If you solid is really only a box or anything in this list there is a simple way :

  • Box
  • Cone
  • Cylinder
  • Sphere
  • Spring
  • Torus

I'll assume it's really a box. Then create your class deriving from solid

public class MyBox : Solid 
{      
    public double Length {get; private set;} = 0d;
    public double Width {get; private set;} = 0d;
    public double Height {get; private set;} = 0d;

    public MyBox() { }

    public MyBox Create(double length, double width, double height)
    {
        var myBox = Solid.CreateBox<MyBox>(length, width, height);

        myBox.Length = length;   
        myBox.Width = width;
        myBox.Height = height;

        return myBox;
    }
}

If you use any other shape of solid you will need to manually create each faces.

Franck
  • 4,438
  • 1
  • 28
  • 55
  • Correct @franck, but now if you have external code that try to change the Length and then you want to update the visualizzation you have to regenerate a new Solid, that's not what I want to do. – elia_c Oct 03 '18 at 16:00
  • 1
    @elia_c You cannot update a solid dimension in any way. That is not possible without transformation. What you want is not possible and the only way you can do it is using a BlockReference and create a 1x1x1 solid and play with the scale property and that will update the box value but a solid is a set of many boolean operations which to get the result you need to compute them every single time – Franck Oct 03 '18 at 16:16