WPF之AnyCAD显示3维坐标系的方式
1.添加AnyCAD包的引用
2.定义AnyCADd的3D坐标系,并与WPF控件绑定
private AnyCAD.Presentation.RenderWindow3d m_RenderView;
public AnyCAD.Presentation.RenderWindow3d RenderView
{
get { return m_RenderView; }
set { m_RenderView = value; }
}
//绑定到WPF控件
System.Windows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost();
this.m_RenderView = new AnyCAD.Presentation.RenderWindow3d();
host.Child = this.m_RenderView;
this.Grid3D.Children.Add(host);
显示效果
3.从本地txt读取3维坐标点信息
List<Vector3> listpoint = new List<Vector3>();
using (StreamReader file = new StreamReader(File.Open(path, FileMode.Open)))
{
char[] separator = { ' ', ',' };//用于分割字符串的标示符号,即空格
string line = file.ReadLine();//读取行;
do
{
string[] newstr = line.Trim().Split(separator);
if(newstr.Length==3)
{
Vector3 curPoint = new Vector3(
Math.Round(Math.Abs(double.Parse(newstr[0])),0),
Math.Round(Math.Abs(double.Parse(newstr[1])),0),
Math.Round(Math.Abs(double.Parse(newstr[2])-1700),0)
);
listpoint.Add(curPoint);
}
line = file.ReadLine();//读取行
} while (line != null);
4.利用读取的点,生成空间多边形
TopoShape ply= GlobalInstance.BrepTools.MakePolyline(listpoint);
m_RenderView.ShowGeometry(ply, 0);
显示效果
注:与微信公众号文章同步https://mp.weixin.qq.com/s?__biz=MzU0MjE4MTc5MQ==&mid=2247483928&idx=1&sn=72d096b94aad5ad556bf3c6127ba3ce5&chksm=fb1fd2e8cc685bfecdf450a5d57aecd4f7066a78d99cfd143336f884c8b629ea083ef365f9ab&token=491782610&lang=zh_CN#rd
扫一扫,了解更多