-1

我是 WPF 新手,无法使用 EyeShot Devdept 将 .stl 文件加载到我的 WPF 应用程序中。谁能给我一些指示?

代码片段:

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);
4

2 回答 2

0

是的,您可能没有看到几何图形,但它已经加载了。尝试调用ViewportLayout.ZoomFit()并将ViewportLayout.Invalidate()其带入视锥体。

于 2016-01-11T08:17:30.707 回答
0

就我个人而言,我喜欢将加载的 STL 和 TypeCast/Clone 放入一个实体中。由于实体是通过引用传递的,因此这是一种创建新实体并将 STL 加载到其中的安全方法。我在那里扔了一些东西,以便在 eyshot 视口中也能轻松查看。重新生成实体并使视口无效是在添加实体后查看实体的关键。只要确保你已经有一个视口。:)

  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);
  }
于 2019-11-20T16:56:16.887 回答