- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello there,
I'm trying to access some material properties but i'm stuck..
I want to change values for these fields. ( see image )
I used this piece of code to access the assetvalue but I cant find a way to set the value of a assetvalue (very confusing I know...
Dim oAssetLib As AssetLibrary
oAssetLib = _invApp.AssetLibraries.Item("MaterialLibrary")
Dim oAsset As Asset
oAsset = oAssetLib.MaterialAssets.Item(1)
For Each oValue As AssetValue In oAsset
Debug.Print(oValue.Name & ": " & oValue.ValueType.ToString)
Next
This resulted in the output.
AssetLibID: kAssetValueTypeString physmat_Comments: kAssetValueTypeString physmat_Cost: kAssetValueTypeString physmat_Keynote: kAssetValueTypeString physmat_Keywords: kAssetValueTypeString physmat_Label: kAssetValueTypeString physmat_Manufacturer: kAssetValueTypeString physmat_Mark: kAssetValueTypeString physmat_Model: kAssetValueTypeString physmat_Type: kAssetValueTypeChoice physmat_URL: kAssetValueTypeString physmat_aspects: kAssetValueTypeReference physmat_class: kAssetValueTypeString
But how can I Set the string value for example "physmat_Cost"? I can't see anything in the API for this?
AssetValue Object
Description The AssetValue object represents a specific value within an asset. The AssetValue class is the base class for the various types of asset values.
| Name | Description |
| Application | Returns the top-level parent application object. When used the context of Inventor, an Application object is returned. When used in the context of Apprentice, an ApprenticeServer object is returned. |
| DisplayName | Gets the name of this value as seen in the Material or Appearance Browser. This can change based on the current Inventor language. |
| IsReadOnly | Gets the boolean flag that indicates if this asset value is read-only. If True any attempted edits will fail. |
| Name | Gets the key name of the value. This name will remain constant for all languages and is the name used as input to the Item property or the Asset object. |
| Parent | Read-only property that returns the parent Asset object. |
| Type | Read-only property returning kAssetValueObject indicating this object’s type. |
| ValueType | Read-only property that returns the data type that the Value property for this AssetValue object will return. |
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hmpppff okay found it myself.
If oValue.ValueType = AssetValueTypeEnum.kAssetValueTypeString Then
Dim oStringAssetValue As StringAssetValue
oStringAssetValue = oValue
Debug.Print(oValue.Name & ": " & oStringAssetValue.Value)
End If
This is really weird in my opinion but, if it works okay
Now to figure out a way to add materials into the library..
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Jef_E
I found something close in what I'm looking in this post.
Can you help me in figuring out how to extract the Category Name from a Library?
I have this code but I just stuck thinking too much
Thank you in advance if you can help me on this matter
Dim oPartDoc = ThisDoc.Document Dim oAssetLib As AssetLibrary oAssetLib = oPartDoc.Item("CategoryName") Dim oAsset As Asset oAsset = oAssetLib.MaterialAssetCategories.Item(1) For Each oValue As AssetCategory In oAsset Debug.Print(oValue.DisplayName) Next