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

推荐订阅源

Recorded Future
Recorded Future
Stack Overflow Blog
Stack Overflow Blog
Cisco Talos Blog
Cisco Talos Blog
Jina AI
Jina AI
S
Schneier on Security
Engineering at Meta
Engineering at Meta
M
MIT News - Artificial intelligence
腾讯CDC
NISL@THU
NISL@THU
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
Recent Announcements
Recent Announcements
博客园_首页
GbyAI
GbyAI
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
V2EX - 技术
V2EX - 技术
美团技术团队
PCI Perspectives
PCI Perspectives
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy International News Feed
Know Your Adversary
Know Your Adversary
人人都是产品经理
人人都是产品经理
C
Cisco Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
博客园 - 叶小钗
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Help Net Security
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
T
Troy Hunt's Blog
Hugging Face - Blog
Hugging Face - Blog
S
Securelist
宝玉的分享
宝玉的分享
N
News | PayPal Newsroom
云风的 BLOG
云风的 BLOG
Security Latest
Security Latest
Project Zero
Project Zero
I
InfoQ
G
GRAHAM CLULEY
博客园 - 司徒正美
C
Check Point Blog
O
OpenAI News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - pensir

ef报错:实体类型XXX不是当前上下文的模型的一部分。 让AutoCAD.NET支持后台线程 将cad嵌入到vb中 sql server 2005 msxml安装失败解决及msxml 6.0 卸载 智能替换DataTable.Select中会导致错误的单引号 - pensir - 博客园 最全ASCII码对照表(备用) C# 删除字符串中任何位置的空格 - pensir - 博客园 在VB.NET中使用MS Access存储过程(转载) Access存储过程,环境:VB 2005+.NET2.0+ACCESS2003(转载) 关键性代码整理 WinForm窗体间传值 WinForm主要控件分类一览 MaskedTextBox掩码元素一览 ArcGIS中的坐标系统 Geodatabase组织结构 GIS关键词 栅格数据与矢量数据 ArcGIS的文件结构 winform+c#之窗体之间的传值 - pensir - 博客园
CADVBA代码移植到.NET
pensir · 2010-04-23 · via 博客园 - pensir

之前写的VBA代码,如果全部用.NET改写,比较劳命伤财,没什么兴趣改写。所以用了一种很偷懒的方法。
       通过com方式调用AutoCAD 200x Type Library,和AutoCAD/ObjectDBX Common xx.x Type Library,定义VBA中的ThisDrawing对象,书写比较规范的VBA代码基本上不用做什么修改就能运行了。
       对于VBA中的窗体,可以先导出为VB窗体,然后用升级向导升级到.NET,做些必要的修改就可以了。
       AutoDesk官方有相关的视频教程,还有个导出VBA到VB的工具。VBA→VB→VB.NET
       相关视频及工具下载地址: http://download.autodesk.com/media/adn/VBA_Migration/DevTV_Recording.zip

[VB.NET]

代码

1 Imports Autodesk.AutoCAD.Interop
2
3  Public Class Class1
4
5 ReadOnly Property ThisDrawing() As Autodesk.AutoCAD.Interop.AcadDocument
6 Get
7 Return Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.AcadDocument
8 End Get
9 End Property
10
11 <Autodesk.AutoCAD.Runtime.CommandMethod("TEST")> _
12 Sub test()
13 ThisDrawing.Utility.Prompt("Hello World!")
14 End Sub
15
16 End Class

[C#] 

代码

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using Autodesk.AutoCAD.Interop;
5
6 namespace CSTest
7 {
8 public class Class1
9 {
10 public static AcadDocument ThisDrawing
11 {
12 get
13 {
14 return (AcadDocument)Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.AcadDocument;
15 }
16 }
17
18 [Autodesk.AutoCAD.Runtime.CommandMethod("TEST")]
19 public void test()
20 {
21 ThisDrawing.Utility.Prompt("Hello World!");
22 }
23
24 }
25 }
26
27