- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
每个已安装的操作系统中都有很多内置的 ThumbnailProvider。由于这些供应商,Windows 能够显示许多文件的缩略图。例如,Windows 资源管理器可以显示 *.jpg 文件的内容,但也可以显示 Solidworks *.sldprt 文件的内容(如果安装了 SolidWorks)。
但是有没有办法得到这些缩略图呢?我尝试使用 Windows API CodecPack 来管理它,但我只在 Windows 7 上成功了。
ShellFile shellFile = ShellFile.FromFilePath(filePath);
Bitmap shellThumb = shellFile.Thumbnail.Bitmap;
问题是:在 Windows XP/Vista 上是否有任何其他可用的方法来获取任何已注册缩略图提供程序的文件的缩略图?我真的很绝望......
最佳答案
有几种方式:
1) 带图书馆OpenMCDF .Solidworks 文件是 Compound document所以访问它的内容 - 正在解析文件。
OpenFileDialog dialog = new OpenFileDialog();
dialog.InitialDirectory = Application.StartupPath;
if (dialog.ShowDialog() == DialogResult.OK)
{
string STORAGE_NAME = dialog.FileName.ToString();
CompoundFile cf = new CompoundFile(STORAGE_NAME);
CFStream st = cf.RootStorage.GetStream("PreviewPNG");
byte[] buffer = st.GetData();
var ms = new MemoryStream(buffer.ToArray());
pictureBox1.Image = Image.FromStream(ms);
}
2) 将库 EModelView.dll 添加为控件并放置到窗体中。
OpenFileDialog dialog = new OpenFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
axEModelViewControl1.OpenDoc(dialog.FileName.ToString(), false, false, true, "");
}
3) 使用 SWExplorer 库 (wpfPreviewFlowControl)
OpenFileDialog dialog = new OpenFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
string sDocFileName = dialog.FileName.ToString();
wpfThumbnailCreator pvf;
pvf = new wpfThumbnailCreator();
System.Drawing.Size size = new Size();
size.Width = 200;
size.Height = 200;
pvf.DesiredSize = size;
System.Drawing.Bitmap pic = pvf.GetThumbNail(sDocFileName);
pictureBox1.Image = pic;
}
3) 使用库文档管理器 (SolidWorks.Interop.swdocumentmgr)
OpenFileDialog dialog = new OpenFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
string sDocFileName = dialog.FileName.ToString();
SwDMClassFactory swClassFact = default(SwDMClassFactory);
SwDMApplication swDocMgr = default(SwDMApplication);
SwDMDocument swDoc = default(SwDMDocument);
SwDMConfigurationMgr swCfgMgr = default(SwDMConfigurationMgr);
string[] vCfgNameArr = null;
SwDMConfiguration7 swCfg = default(SwDMConfiguration7);
IPictureDisp pPreview = default(IPictureDisp);
SwDmDocumentType nDocType = 0;
SwDmDocumentOpenError nRetVal = 0;
SwDmPreviewError nRetVal2 = 0;
Image image = default(Image);
//Access to interface
swClassFact = new SwDMClassFactory();
swDocMgr = (SwDMApplication)swClassFact.GetApplication("Post your code here");
swDoc = (SwDMDocument)swDocMgr.GetDocument(sDocFileName, nDocType, false, out nRetVal);
Debug.Assert(SwDmDocumentOpenError.swDmDocumentOpenErrorNone == nRetVal);
swCfgMgr = swDoc.ConfigurationManager;
pathLabel.Text = "Path to file: " + swDoc.FullName;
configLabel.Text = "Active config: " + swCfgMgr.GetActiveConfigurationName();
vCfgNameArr = (string[])swCfgMgr.GetConfigurationNames();
foreach (string vCfgName in vCfgNameArr)
{
//get preview
swCfg = (SwDMConfiguration7)swCfgMgr.GetConfigurationByName(vCfgName);
pPreview = (IPictureDisp)swCfg.GetPreviewPNGBitmap(out nRetVal2);
image = Support.IPictureDispToImage(pPreview);
//insert to picturebox
pictureBox1.BackgroundImage = image;
}
swDoc.CloseDoc();
}
关于c# - 获取任何文件的缩略图,包括 Windows XP/Vista 上的 SolidWorks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11888025/
有没有一种方法可以查看 solidworks 文件而不将其转换为 edrawing? 最佳答案 eDrawings 数据嵌入到文件中。这非常适合查看图纸。您不必加载零件或装配体。使用 IEModelV
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 2年前关闭。 Improve this questi
我的一个 friend 想让我编写一个简单的程序,打印一些文件。 这些文件的格式为.SLDDRW (Solidworks) 如果机器上安装了该软件,有没有简单的方法来打印文件。我只是不知道这是某种 C
我有一个在 32 位和 64 位操作系统上运行的 c# 应用程序。在我的应用程序中,我如何以编程方式检查计算机上是否安装了 solidworks。如果我们可以通过读取注册表项来检查它,那么为我提供 3
我正在尝试使用 VBA 在 Solidworks API 中运行一个挤压循环。每个挤压的高度由位图中像素的亮度决定。 在大多数情况下,代码按预期工作,但是大约四分之一的挤压根本不起作用。草图是制作的,
情况 在工作中,我们使用Solidworks来开发我们制造的产品的3D模型。除了Solidworks,我们还使用外接程序SolidCAM来计算将发送到生产环境的机器时间。 问题 加载SolidCAM文
目前我正在从事创建用于以 OBJ 格式导出 3D 模型的 SolidWorks 插件。 OBJ打开很简单的格式 我在谷歌上搜索并找到了有关现有解决方案的以下信息:有几个付费插件和 1 个免费插件,称为
我正在创建一个用于渲染 solidworks 模型的宏。它旨在呈现装配中的所有配置。我正在处理的一段代码必须提取所有配置的质量并将其放在渲染名称的末尾。对于大多数配置,这都有效。 只有装配中没有模型的
我正在为我们的制造部门开发 C# VSTA 宏。我使用 SldWorks.GetPreviewBitMapFile 保存所选模型的位图预览并将其显示在图片框中,如下所示: 除了奇怪的颜色之外,代码看起
我正在尝试使用 AngelSix 的 SolidDna 库创建一个 Solidworks 插件。我按照示例使用了标准设置: public class Integration : AddInIntegr
我正在 SolidWorks VBA 中编写一个宏,该宏应该打开装配体的所有零件并更新其设计表。当装配和零件复制到新位置时,我希望宏在新位置打开新(复制的)零件。如何引用部件的相对路径而不是绝对路径。
SolidWorks 使用 VBA 作为其宏,但它与 Excel VBA(这是我习惯的)有很大不同。它们使得在 SW 中操作字符串变得非常困难(而且很可能是不可能的)。我尝试过使用 Left() 函数
我在 Solidworks 插件中有几个函数调用 VBA 宏(通过 runMacro2 方法),这是一位同事在过去几周一直在研究的。在他的代码中,他调用了一个 Solidworks 函数,该函数在某些
是否有一个库可以将 edrawings 加载到 JFrame 中? 最佳答案 如果您愿意将输入文件限制为 DXF 文件,也许这样可以吗? http://www.escape.de/~quincunx/
我想从另一个应用程序打开/启动 Solidworks PDM 中的文件夹。 我正在使用 C# 并使用此代码: Process.Start(@"C:\Sandbox\Test"); Sandbox 目录
我在 Solidworks 中有一个装配体模型。 我将 API C# 用于 Solidworks 以自动创建模型。 而且我不明白我需要如何编写才能在零件上创建线性模式。 这是我的代码: public
首先请注意,我的计算机上没有安装 solidworks,但将这些文件用于项目。 Solidworks 能够为文件属性制作自定义选项卡。在此选项卡中,您可以找到有关在 solidworks 中制作的模型
我目前正在开发一个新的 Solidworks 任务 Pane ,主要是实现一些我以更方便的格式编写的“旧”宏。其中一些需要用户通过文本框输入,我想将其包含在任务 Pane 中。 问题是,我找不到编写临
打开我遇到问题的行时我无法修改设计表是 var sheet = (Excel._Worksheet)swDoc.GetDesignTable; .基本上我想要它做的是打开窗口并引用事件表,即“设计表”
我想知道如何通过使用 VBA 的 API 访问 SolidWorks 特征树中不同对象的坐标。我个人的问题是找到正确的语句来提取根据所选对象而变化的位置数据。我的对象是通过它们自己的坐标系和原点来描述
我是一名优秀的程序员,十分优秀!