I’m trying to use 2D plane for my own things, but I was totally lost in making a single line. I found how to switch to 2D drawing, found IDrawingView that looking reliable for making any figure, but I don’t understand how to make ILineSet or where I can get objects that realize this interface.
public void draw()
{
var context = IoC.Get<IApplicationContext>();
IoC.Get<IApplication>().DrawingContext = true;
ISimWorld drawingWorld = IoC.Get<IApplication>().DrawingWorld;
\\it works
IAnnotation ann = drawingWorld.CreateLayoutItem<IAnnotation>("hello");
ann.Text = "Hello world";
\\how to make it work?
IDrawingView line = drawingContext.CreateLayoutItem<IDrawingView>("rect");
Vector3 topleft = new Vector3(100, 10, 0);
Vector3 topright = new Vector3(100, 200, 0);
???
rect.SetLines(???);
}
Tried to make my own realization of ILineSet interface like in the code below, but program tell me, that
"Unhandled exception occurred:EXCEPTION_ACCESS_VIOLATION "
class Rect : ILineSet
{
private List<Vector3[]> InternalLines = new List<Vector3[]>();
...
public ReadOnlyCollection<Vector3[]> Lines
{
get {
return InternalLines.AsReadOnly();
}
}
...
public void AddLine(Vector3 point1, Vector3 point2)
{
Vector3[] vector = new Vector3[2];
vector[0] = point1;
vector[1] = point2;
InternalLines.Append(vector);
//Lines.Append<Vector3>(point1);
}
in draw function
....
IDrawingView rect = drawingWorld.CreateLayoutItem<IDrawingView>("hello");
Vector3 topleft = new Vector3(100, 10, 0);
Vector3 topright = new Vector3(100, 200, 0);
Rect myRect = new Rect();
myRect.AddLine(topleft, topright);
List<ILineSet> liseSet = new List<ILineSet> { myRect };
IEnumerable<ILineSet> test = liseSet.AsEnumerable<ILineSet>();
rect.SetLines(test);
....