AutoCAD的粘贴板管理器

ClipboardManager是一款由Mark Dubbelaar开发的实用工具,该工具能够记录AutoCAD中用户复制到剪贴板的内容,并允许用户通过简单界面进行管理和粘贴。通过钩住COPYCLIP命令并使用Win32 API,该工具实现了类似Microsoft Office中“剪贴板环”的功能。

Kean的博客Through the interface中最近介绍了一个叫做Clipboard Manager的工具。这个小东西可以把AutoCAD里面用户复制到粘贴板里的东西一项一项的显示在一个简单的属性面板(palette)中,而且还显示出复制的时间信息,然后用户可以用palette中的右键菜单中几种粘贴方式进行粘贴。

这个软件神奇的地方是它用了钩子来钩AutoCAD中的COPYCLIP命令,然后用到了win32中的SetClipboardViewer方法来把它自己作为粘贴板浏览器(clipboard viewer)。这个功能主要是在CbPalette类中实现的。

你可以从Autodesk Labs里面下载到Clipboard Manager source code源代码。

Kean的博客中显示了他用AutoCAD2010演示了这个工具。但是我下载到的源代码只能用AutoCAD2009和之前版本编译运行。好像是.NET库版本不兼容。可能重新建一个工程然后把那些类文件加进去也能解决这个问题。我没有试。大家如果有兴趣可以自己尝试。

这个软件工具也演示了如何用VB.NET实现按需加载。Kean以前曾提供过一个C#来实现按需加载功能的文章。

下面是原文:

Clipboard Manager: October's ADN Plugin of the Month, now live on Autodesk Labs

As Scott is leaving on a well-deserved sabbatical, he has gone ahead and posted our next Plugin of the Month a few days ahead of schedule. Here's a link to Scott's post announcing the tool.

This is a very cool little application developed by Mark Dubbelaar from Australia. Mark has been drafting/designing with AutoCAD for the last 10+ years and, during this time, has used a variety of programming languages to customize AutoCAD: LISP, VBA and now VB.NET. Mark was inspired by the "clipboard ring" functionality that used to be in Microsoft Office (at least I say "used to be" because I haven't found it in Office 2007), and decided to implement similar functionality in AutoCAD.

The implementation of the tool is quite straightforward but the functionality is really very compelling: after having NETLOADed the tool and run the CLIPBOARD command, as you use Ctrl-C to copy drawing objects from inside AutoCAD to the clipboard a custom palette gets populated with entries containing these sets of objects. Each entry contains a time-stamp and an automatically-generated name which you can then change to something more meaningful.

When you want to use these clipboard entries, you simply right-click on one and choose the appropriate paste option (which ultimately just calls through to the standard AutoCAD paste commands, PASTECLIP, PASTEBLOCK and PASTEORIG, reducing the complexity of the tool).

That's really all there is to it: a simple yet really useful application. Thanks for providing such a great little tool, Mark! :-)

Under the hood, the code is quite straightforward. The main file, Clipboard.vb, sets up the application to create demand-loading entries when first loaded into AutoCAD and defines a couple of commands – CLIPBOARD and REMOVECB, which removes the demand-loading entries to "uninstall" the application. It also contains the PaletteSet that contains our CbPalette and gets displayed by the CLIPBOARD command.

It's the Clipboard_Palette.vb file that contains the more interesting code, implementing the behaviour of the CbPalette object. The real "magic" is how it hooks into AutoCAD's COPYCLIP by attaching itself as the default "clipboard viewer".

I also added a VB.NET version of the C# code that automatically registers an AutoCAD .NET application for demand-loading based on the commands it defines:

That's really all there is to it. If you have any feedback regarding the behaviour of the tool, please do send us an email.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值