Inventor 2014 API 新功能 (9) Autodesk材质库(下)

这篇博客介绍了Inventor 2014 API中的新特性,重点关注Autodesk材质库。通过API,可以访问和操作材质库中的不同对象,包括AssetLibraries集合、AssetCategories、AssetCategory以及Asset。每个Asset包含多种类型的属性,如Boolean、Choice、Color等,提供对材料和外观的详细定制。
摘要由CSDN通过智能技术生成

API 提供了全面的材质库相关对象和方法。首先看看对象层次结构。

在Application下有AssetLibraries 集合,表示的所有材质库(AssetLibrary),包括自定义的材质库。每个库中有类别集合,叫做AssetCategories, 每个类别叫做AssetCategory,每类中的具体是具体的材质(材料或外观),都叫做Asset。Asset的属性是AssetValue的集合, 所有asset 是以下类型值的集合:

  • Boolean
  • Choice
  • Color
  • Filename
  • Float
  • Integer
  • Reference
  • String
  • Texture



这里有段代码,用来访问文档所有Asset的信息。

Public Sub DumpDocumentAppearances()
    ' 当前文档是装配或零件.
    If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject And ThisApplication.ActiveDocumentType <> kPartDocumentObject Then
        MsgBox "A part or assembly must be active."
        Exit Sub
    End If
    
    Dim doc As Document
    Set doc = ThisApplication.ActiveDocument
    
    ' 信息写入一个文本文件
    Open "C:\Temp\DocumentAppearanceDump.txt" For Output As #1
    ' 遍历文档中每个材质    
     Dim appearance As Asset
      For Each appearance In doc.AppearanceAssets 
		Print #1, " Appearance" 
		Print #1, " DisplayName: " & appearance.DisplayName 
		Print #1, " HasTexture: " & appearance.HasTexture 
		Print #1, " IsReadOnly: " & appearance.IsReadOnly 
		Print #1, " Name: " & appearance.Name
	       ' 遍历材质所有属性
	      Dim value As AssetValue 
	      For Each value In appearance 
			Call PrintAssetValue(value, 8) 
	       Next 
	Next 
	Close #1 
	MsgBox "Finished writing output to ""C:\Temp\DocumentAppearanceDump.txt"""
	
End Sub

 ' 打印材质Value的具体信息
Private Sub PrintAssetValue(InValue As AssetValue, Indent As Integer)
    Dim indentChars As String
    indentChars = Space(Indent)
    
    Print #1, indentChars 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值