-2

I am new to WPF and I am unable to load a .stl file ínto my WPF application using EyeShot Devdept. Can anyone provide me with some pointers?

Code Snippet:

Entity[] entList;

// loads the file contents in the entList array
singleViewportLayout1.ReadSTL("fileName.stl", out entList);

// adds the entList to the entities collection
singleViewportLayout1.Entities.AddRange(entList);
Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
  • you'll have to include the code that you have tried – Wim Ombelets Mar 13 '14 at 12:21
  • singleViewportLayout1.ReadSTL("fileName.stl") automatically adds it to the viewport, then you can do a viewportLayout1.ZoomFit(); in order to navigate yourself to the object, in the off case that you use a weird coordinate system. – elasticrash Apr 03 '14 at 15:33

2 Answers2

0

Yes, you probably aren't seeing the geometry but it's already loaded. Try calling ViewportLayout.ZoomFit() and ViewportLayout.Invalidate() to bring it inside the viewing frustum.

abenci
  • 8,422
  • 19
  • 69
  • 134
0

Personally I like to take the loaded STL and TypeCast/Clone it into an entity. Since entities are referenced passed this is a safe way to create a new entity and get your STL loaded into it. I tossed a few things in there to make it easy to view in the eyshot viewport as well. Regenerating the entites, and invalidating the viewport are key to seeing your entity after it has been added. Just make sure you already have a viewport. :)

  string Path_STL = "C:\\Users\\bdg\\Documents\\TestSTL.stl";
  try
  {
    var currSTL = new ReadSTL(Path_STL);
    currSTL.DoWork();

    Entity ent = (Entity)currSTL.Entities[0].Clone();
    ent.ColorMethod = colorMethodType.byLayer;
    ent.LayerName = "TestLayer";
    ent.EntityData = "TestSTL";

    viewportLayout1.Entities.Add(ent);
    viewportLayout1.Layers[ent.LayerName].Color = Color.Aquamarine;

    viewportLayout1.Entities.Regen();
    viewportLayout1.Invalidate();
    viewportLayout1.ZoomFit();
  }
  catch (Exception ex)
  {
    Console.WriteLine("Load STL Failed: " + ex);
  }
Brendan Getz
  • 71
  • 1
  • 5