概述
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.
最后
以上就是坦率中心为你收集整理的AutoCAD的粘贴板管理器的全部内容,希望文章能够帮你解决AutoCAD的粘贴板管理器所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复