修改Client Feature的图标

来源:互联网 发布:全知之眼 编辑:程序博客网 时间:2024/06/05 11:52

如前篇文章看到的,Client Feature默认有个图标,类似方程式的样子。那可不可以设置自己的图标呢?是可以的。




方法很简单。只需要调用Client Feature对应浏览节点的BrowserNodeDefinition.OverrideIcon,设置为需要的icon,但前提是OverrideIcon已经是一个面板资源,所谓面板资源,就是无论Inventor本身的浏览面板或者自定义的BrowserPane, 都有ClientNodeResources,ClientNodeResources.Add添加自定义资源。

下面的代码,假定有个零件文档,其中有特征1和特征2, 首先创建Client Feature,添加特征1和特征2,然后将c:\temp下的某bitmap作为资源添加到ClientNodeResources,最后使用该资源重载Client Feature的图标。


Sub CGInClientFeatureTest()Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument   Dim oDef As PartComponentDefinition Set oDef = oDoc.ComponentDefinition  ‘get first and second features Dim oPartFea1 As PartFeature Set oPartFea1 = oDef.Features(1)     Dim oPartFea2 As PartFeature Set oPartFea2 = oDef.Features(2)      'create client feature definition Dim oClientFeatureDef As ClientFeatureDefinition Set oClientFeatureDef = oDef.Features.ClientFeatures.CreateDefinition("ClientFeatureTest")     ‘add the part features to client feature oClientFeatureDef.ClientFeatureElements.Add oPartFea1 oClientFeatureDef.ClientFeatureElements.Add oPartFea2   'create client feature Dim oClientFeature As ClientFeature Set oClientFeature = oDef.Features.ClientFeatures.Add(oClientFeatureDef, "ClientIDString") 'get the browser node of the client feature      Dim oNode As BrowserNode         Set oNode = oDoc.BrowserPanes(1).GetBrowserNodeFromObject(oClientFeature)        'create the resource of icon. assume a bitmap 1.bmp exists  ‘ in c:\temp         Dim oCnr As ClientNodeResource                 Dim oIcon As IPictureDisp         Set oIcon = stdole.LoadPicture("C:\temp\1.bmp")                 ' Create a client node resource.         Set oCnr = oDoc.BrowserPanes.ClientNodeResources.Add("SamplePocketFeature", -1, oIcon)        ' Override the icon for the client feature.         oNode.BrowserNodeDefinition.OverrideIcon = oCnr        ThisApplication.ActiveView.Update End Sub

2015-01-15_1412


推荐论坛阅读:

焊接件文档里为何不支持Client Feature?

http://forums.autodesk.com/t5/inventor-customization/clientfeature-in-weldment/m-p/5104022/highlight/true#M50438


0 0