I had a comment on one of the previous posts about iProperties asking about how to present the user a list of valid entries for an iProperty. It’s a good question and would be a useful feature, but is not something that Inventor supports. However, that’s an advantage of learning to program because you can create new functionality and add support for this yourself, which I’ve demonstrated below.
大家知道,iProperties自带有一个自定义特性集合,在用户界面或者API都可访问到。API还可以增加更多的自定义特性集合,而这些是用户界面看不到的。通常情况下,在一些二次开发软件流程里,不希望最终用户看到。但有的程序却需要。这时Inventor自带的iProperties对话框就不够用了。但对于编程人员来讲,其实这根本就是小小菜一碟。
I’ve written a sample program to demonstrate one possible solution to this problem. The program is an Inventor add-in. It adds a new command to the application menu in the ribbon, as shown below. (It will add it to the File menu if you’re using the classic user-interface.) I chose to call the command iProperties+.
Brian根据这个需求写了个小程序-插件。添加一个命令到大I菜单下,见下图。当然,添加到什么地方随意。
When the command is executed it brings up a custom iProperties dialog, as shown below.
执行该命令,弹出如下的对话框,其中列出了一些iProperries。
This dialog provides access to some of the standard iProperties plus an additional custom iProperty (Finish). It has the advantage of providing a simplified view of the iProperties where only those iProperties that are important for your workflow are shown. This makes it faster to enter the values and much easier since you’re not having to navigate through several tabs to remember and find the iProperties you need to fill out.
这个对话框可以访问Inventor iProperties已经有的特性项目,也可让你只显示你认为重要的项目,另外,它的操作性和便捷性比Inventor自己的强很多。
Another advantage is that since this is a custom dialog you can choose to present the iProperties in any form you want. For example, Finish, Material, and Approved By are implemented as combo boxes allowing you to present the user with a list of valid values. The picture below shows the drop-down list when the Finish field is selected. Using the drop-down makes is even easier for the user and eliminates any mistakes from typing.
当然,由于这个对话框是你自己的,你可以按照自己的意愿呈现信息。
Here is the source code for this sample. It’s written using Visual Basic Express 2008 and is compatible with Inventor 2010 and later since it expects the ribbon to be available. I don’t think the program is very useful as-is since everyone will have different requirements as far as which properties they want to display. In my sample I chose to use an external file to define the contents of the drop-down lists so they could be easily updated without modifying any code. If you want to see the program run, you just need to open the source within VB Express and compile it. This will compile and register it on your system so that when you start Inventor you should see the “iProperties +” icon in the Application menu.
通过这个链接source code 可下载到源代码。是用VB.NET写的。这只是个大概的框架,你可以参考,修改满足你的需求。为简便起见,该程序有一个外部文件,定义下拉列表的内容,这样可以很方便的定制下拉框内容。注意,这个是注册型插件。如果你具备了免注册插件的知识,可以自行改造。
The use of iProperties within the program is the most important part of the program but is also a small portion of the code. There is quite a bit of add-in code and also a fair amount of code to deal with the dialog. Updating this program for your specific needs would be a good project to get you going in the world of add-in development using VB.Net. For some background on add-ins and user-interface customization you might want to read these other posts; Accessing iProperties,Custom iProperties, and Supporting the Ribbon User Interface.