©2013AutodeskAutodesk标准材料库API使用技巧张宇寒产品设计师DevCamp2013©2013Autodesk内容何为一致材料旧的样式库新的资源库新的资源库API结构及示例©2013Autodesk何为一致材料欧特克标准库-多款软件使用一致的材料和外观库欧特克多种产品共享材料和外观库材料和外观定义的统一可实现更一致的可视化、材料用法和分析,并提高质量控制。©2013Autodesk何为一致材料欧特克标准库-多款软件使用一致的材料和外观库©2013Autodesk何为一致材料Inventor使用的材料库和外观库AutodeskInventor材料库Autodesk材料库Autodesk外观库©2013Autodesk旧的样式库颜色(Color)RenderStyle隐藏©2013Autodesk旧的样式库材料(Material)Material隐藏©2013Autodesk新的资源库资源(Asset)资源(Asset):可以是一个外观或者材料,甚至是一个材料的物理特性的集合©2013Autodesk新的资源库Inventor的外观库AppearanceAsset©2013Autodesk新的资源库Inventor的材料库MaterialAsset©2013Autodesk新的资源库移植样式库到资源库©2013Autodesk新的资源库API结构及示例新的资源库API结构资源Asset外观资源AppearanceAsset材料资源MaterialAsset物理特性资源PhysicalPropertiesAsset外观资源AppearanceAsset物理特性资源PhysicalPropertiesAsset©2013Autodesk新的资源库API结构及示例新的资源库API结构ApplicationAssetLibrariesAssetsEnumeratorAssetLibraryAssetsEnumeratorAssetsCategoriesAssetCategoryAssetAssetAssetValueAssetValue资源库资源分类资源资源特性值©2013Autodesk新的资源库API结构及示例新的资源库API结构PartDocumentAppearanceAssetsMaterialAssetsAssemblyDocumentPresentationDocument©2013Autodesk新的资源库API结构及示例新的资源库API结构AssetAssetLibraryAssetCategoryAssetValueAssetsEnumerator©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)AssetValue是一个对象具体类型BooleanAssetValueChoiceAssetValueColorAssetValueFilenameAssetValueFloatAssetValueIntegerAssetValueReferenceAssetValueStringAssetValueTextureAssetValue©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)BooleanAssetValuecommon_Tint_togglePrivatem_appAsInventor.ApplicationSubToggleTintColorToggle()m_app=GetObject(,Inventor.Application)DimoDocAsPartDocumentoDoc=m_app.ActiveDocumentDimoAppearanceAssetAsInventor.AssetoAppearanceAsset=oDoc.AppearanceAssets.Item(1)DimoBooleanAssetValueAsBooleanAssetValueoBooleanAssetValue=oAppearanceAsset.Item(common_Tint_toggle)‘反选染色的开关设置oBooleanAssetValue.Value=Not(oBooleanAssetValue.Value)EndSub©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)ChoiceAssetValuePrivatem_appAsInventor.ApplicationSubGetMatChoices()m_app=GetObject(,Inventor.Application)DimoDocAsPartDocumentoDoc=m_app.ActiveDocumentDimoMatAssetAsInventor.AssetoMatAsset=oDoc.MaterialAssets.Item(1)DimoChoiceAssetValueAsChoiceAssetValueoChoiceAssetValue=oMatAsset.Item(physmat_Type)DimnamesAsString()=NewString(){}DimchoicesAsString()=NewString(){}CalloChoiceAssetValue.GetChoices(names,choices)DimsMsgAsString=Choices:&vbCrLf'输出所有的材料类型选项DimiAsIntegerFori=0ToUBound(names)sMsg=sMsg&&names(i)&,&choices(i)&vbCrLfNextMessageBox.Show(sMsg,PhysicalMaterialTypes)EndSub©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)ColorAssetValuecommon_Tint_colorPrivatem_appAsInventor.ApplicationSubChangeTintColor()m_app=GetObject(,Inventor.Application)DimoDocAsPartDocumentoDoc=m_app.ActiveDocumentDimoAppearanceAssetAsInventor.AssetoAppearanceAsset=oDoc.AppearanceAssets.Item(1)DimoColorAssetValueAsColorAssetValueoColorAssetValue=oAppearanceAsset.Item(common_Tint_color)DimoNewColorAsColoroNewColor=m_app.TransientObjects.CreateColor(255,128,0)'改变染色的颜色oColorAssetValue.Value=oNewColorEndSub©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)Filename参见Texture代码示例©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)FloatAssetValuegeneric_reflectivity_at_0degPrivatem_appAsInventor.ApplicationSubChangeReflectivityValue()m_app=GetObject(,Inventor.Application)DimoDocAsPartDocumentoDoc=m_app.ActiveDocumentDimoAppearanceAssetAsInventor.AssetoAppearanceAsset=oDoc.AppearanceAssets.Item(1)DimoFloatAssetValueAsFloatAssetValueoFloatAssetValue=oAppearanceAsset.Item(generic_reflectivity_at_0deg)'改变0度角方向的反射率oFloatAssetValue.Value=0.8EndSub©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)Integergeneric_refr_depth(AppearanceAsset)©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)Referencephysmat_aspectsPrivatem_appAsInventor.ApplicationSubChangeTintColor()m_app=GetObject(,Inventor.Application)DimoDocAsPartDocumentoDoc=m_app.ActiveDocumentDimoMatAssetAsInventor.MaterialAssetoMatAsset=oDoc.MaterialAssets.Item(1)DimoReferenceAssetValueAsReferenceAssetValueoReferenceAssetValue=oMatAsset.Item(physmat_aspects)Debug.Print(oReferenceAssetValue.DisplayName)'获得引用的外观和物理特性资源DimoRefAppearanceAsAsset,oRefPhyPropertiesAsAssetoRefAppearance=oMatAsset.AppearanceAssetoRefPhyProperties=oMatAsset.PhysicalPropertiesAssetEndSub©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)StringAssetLibID(资源库的guid)©2013Autodesk新的资源库API结构及示例资源的特性值(AssetValue)TexturePrivatem_appAsInventor.ApplicationSubGetTextureAndFilenameAssetValue()m_app=GetObject(,Inventor.Application)DimoAssetLibAsAssetLibrary'AutodeskAppearanceLibraryoAssetLib=m_app.AssetLibraries(314DE259-5443-4621-BFBD-1730C6CC9AE9)'获得某个具有纹理的资源DimoAssetAsAssetoAsset=oAssetLib.AppearanceAssets(Plastic-049)If(oAsset.HasTexture)Then'获得资源的纹理特性值DimoTextureAssetValueAsInventor.TextureAssetValueoTextureAssetValue=oAsset.Item(plasticvinyl_bump_map)'获得资源纹理对象DimoAssetTextureAsAssetTextureoAssetTexture=oTextureAssetValue.Value'获得FilenameAssetValue,即纹理使用的图片DimoFilenameAssetValueAsFilenameAssetValueoFilenameAssetValue=oAssetTexture.Item(unifiedbitmap_Bitmap)