惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - DarkAngel

好久未登陆 签到 Silverlight 3正式版新鲜出炉 Silverlight3的7个新功能[转] 一个端口扫描的小程序 WEBPART结合实际的应用(.Net2005) 带验证功能的的TextBox 一个很老的故事: 水和鱼的故事 Browser.Net浏览器c#开发(开源) 吉祥三宝(设计篇) - DarkAngel - 博客园 将指定网页添加到收藏夹的方法(c#) Microsoft.Press.Microsoft.Visual.C.Sharp.2005.Step.by.Step.Oct.2005 取客户端MAC地址的方法 关于在活动目录(ACTIVE DIRECTORY)中创建组织单位和用户 Exchange 2k的安装与删除。 无 Cookie 的 ASP.NET 一个任意获得页面控件的方法 跨页面的多选功能实现 买不起笔记本,只好自己动手做一个啦-!(转)
读取DWG文件中的文本信息(CAD2004)
DarkAngel · 2007-05-23 · via 博客园 - DarkAngel

  还是那句话,工作需要,不然是不会研究这个的.也许有的人会遇到跟我一样的问题,有兴趣看看,可以节约点时间.运行时要引用CAD2004的COM,这种读取文本的方式并不好,需要机器上装有AUTOCAD2004,而且针对不同的版本,程序可能要进行修改,如果有朋友能有比较好的解决方法,或者第三方控件,欢迎联系.下面将代码贴上:

 1using System;
 2using System.Collections.Generic;
 3using System.Text;
 4using System.IO;
 5
 6namespace AutoCADFilter
 7{
 8    public class Filter
 9    {
10        public Filter()
11        {
12            
13        }

14        /// <summary>
15        /// 读取dwg文件中的文本信息
16        /// </summary>
17        /// <remarks>读取dwg文件中的文本信息</remarks>
18        /// <returns>文本内容</returns>

19        private string ReadDwg(string path)
20        {
21       
22            string content = "";
23            string filename = "";
24            FileInfo finfo = new FileInfo(path);
25            filename = finfo.Name;
26            AutoCAD.AcadApplication ap = new AutoCAD.AcadApplication();
27            lock (ap)
28            {
29                try
30                {
31                    AutoCAD.AcadDocument ad = ap.Documents.Open(path,truenull);
32                    for (int i = 0; i < ad.ModelSpace.Count; i++)
33                    {
34                        if (ad.ModelSpace.Item(i).ObjectName.ToLower().Equals("acdbmtext"))
35                        {
36                            AutoCAD.IAcadMText im = (AutoCAD.IAcadMText)ad.ModelSpace.Item(i);
37                            content += im.TextString;
38                        }

39                        else if (ad.ModelSpace.Item(i).ObjectName.ToLower().Equals("acdbtext"))
40                        {
41                            AutoCAD.IAcadText im = (AutoCAD.IAcadText)ad.ModelSpace.Item(i);
42                            content += im.TextString;
43                        }

44                    }

45                    ad.Close(false, filename);
46                }

47                finally
48                {
49
50                    ap.Quit();
51                }

52            }

53            return content;
54        }

55
56        public string Parse(string path)
57        {
58            return ReadDwg(path);
59          
60        }

61    }

62}