我是靠谱客的博主 结实母鸡,最近开发中收集的这篇文章主要介绍NX二次开发 获取部件的预览图,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述


/// <summary>
/// 获取部件的预览图
/// </summary>
/// <param name="part">部件对象</param>
/// <returns></returns>
public static Bitmap GetPreview(Part part)
{
part.GetPreviewImage(out int width, out int height, out int[] pixels);
if (width > 0 && height > 0)
{
Bitmap bm = new Bitmap(width, height);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int pixel = pixels[y * width + x];
Color col1 = Color.FromArgb(pixel);
Color col2 = Color.FromArgb(255, col1);
bm.SetPixel(x, y, col2);
}
}
return bm;
}
else
{
MessageBox.Show("Part has no valid preview", "Information");
return null;
}
}

最后

以上就是结实母鸡为你收集整理的NX二次开发 获取部件的预览图的全部内容,希望文章能够帮你解决NX二次开发 获取部件的预览图所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部