用API实现在位输入标题栏内容

上一篇文章,我们创建了自己的对话框进行iProperties的输入。本篇文章将介绍一个不错的例子,是Brian编写的,用来实现工程图标题栏内容的输入。原文地址:

http://modthemachine.typepad.com/my_weblog/iproperties/

When writing theprevious postabout a custom dialog for iProperty entry I had forgotten about another example I had put together a couple of years ago. This is similar but I think is better at demonstrating how useful this concept can be. In this case there’s a custom dialog that looks like a title block. This significantly simplifies filling out the title block. Instead of the user having to search through the iProperties dialog and remember which property corresponds to which field on the title block they just fill out the title block directly. For this example, one of the fields is also a prompted text entry to demonstrate that you’re not limited to only using iProperties. This sample doesn’t demonstrate it but it could also use drop-down fields with lists like that shown in theprevious post.

Inventor工程图里标题栏里的内容由标题栏定义设置,其中有三种文字:普通静态文字:即定义里是什么内容,标题栏显示的就是什么提示文字: 当标题栏插入时,会有一个字串提示该是什么方面的内容,由用户自己输入最终的显示内容关联文字:定义时该文字和某个文档iProperties关联,当标题栏插入时,自动找到对应iProperties的内容

总之,没有一个直观的标题栏编写方式。

When the program is run, this is what the user sees. It’s a VBA dialog that was created by doing a screen shot of the title block and inserting that as an image on the dialog. The various text controls were added on top of the image.

Brian用VBA写了个小例子,根据某种工程图标题栏样式,创建出一个在位编辑的对话框,和在图纸看到的对应,如下图

One the dialog is filled out and the “Apply” button is pressed it sets the corresponding iProperties and the prompted text and then the title block automatically updates to reflect those changes. Here’s the result.

用户可以在这里,直接进行输入,点击Apply后,标题栏就显示出输入的内容,达到“所见即所得”。

Here’s azip filecontaining a sample drawing that has the custom iProperties and the prompted text field the sample program expects and it contains a VBA project that contains the source code. If you want to implement this within your company I would recommend writing this as an add-in rather than VBA, like theprevious postdemonstrates.

这个例子的源代码可在这里下载zip file,其中包括了测试的工程图和自定义的iProperties。因为标题栏样式是多样的,你需要根据具体的样式,让对话框的样式自动的进行匹配。另外,最好写成插件,而不是用VBA。

一定要成为你工作最大的资产。

用API实现在位输入标题栏内容

相关文章:

你感兴趣的文章:

标签云: