inventor api creating appearances "Wood" type does not work

inventor api creating appearances "Wood" type does not work

kurzwil40
Participant Participant
918 Views
5 Replies
Message 1 of 6

inventor api creating appearances "Wood" type does not work

kurzwil40
Participant
Participant

Hello all,

 

  I am creating libraries and appearances programmatically through the api. My problem is that when trying to create new "appearances" to populate the library I have created I run into an issue with the "Wood" type. All other appearance types seems to work fine and create a new appearance when using the function for creating new appearances:

 

asLibAp = docAssets.Add(AssetTypeEnum.kAssetTypeAppearance, "Plastic", assetName, assetName & "1") - works fine creates appearance

asLibAp = docAssets.Add(AssetTypeEnum.kAssetTypeAppearance, "Generic", assetName, assetName & "1")- works fine creates appearance

asLibAp = docAssets.Add(AssetTypeEnum.kAssetTypeAppearance, "Masonry", assetName, assetName & "1")- works fine creates appearance

asLibAp = docAssets.Add(AssetTypeEnum.kAssetTypeAppearance, "Generic", assetName, assetName & "1")- works fine creates appearance

 

etc.. all work, but the "Wood" type

 

asLibAp = docAssets.Add(AssetTypeEnum.kAssetTypeAppearance, "Wood", assetName, assetName & "1")- throws an error every single time and will 

not create an appearance. Is the api type(input for this wrong? Does the wood type need to be called something else. Was it misspelled in the type library or enumerations or what the function is looking for as one of the keywords and so "Wood" is not recognized?

 

Will this be fixed (patched) for Inventor 2016 api?

 

 

 

0 Likes
919 Views
5 Replies
Replies (5)
Message 2 of 6

JarFu
Autodesk
Autodesk

Thanks your reporting and good catch! I'll forward this bug to team for the further fix. Will let you know when there is any update.

LocalType API help, this method does not work when use Hardwood neither:

The valid types of assets that can be created are: “Ceramic”, “Concrete”, “Generic”, “Glazing”, “Hardwood”, “MasonryCMU”, “Metal”, “MetalicPaint”, “Mirror”, “PlasticVinyl”, “SolidGlass”, “Stone”, “WallPaint”, and “Water”.



Jar Fu
SW Engineer
Inventor QA
Autodesk, Inc.
0 Likes
Message 3 of 6

thom-g
Advocate
Advocate

@JarFu: not only HardWood does not work. I tested all valid types according to the list in the API Help:

 

  • Ceramic
  • Concrete
  • Generic
  • Glazing
  • Hardwood     HRESULT: 0x80070057 (E_INVALIDARG)
  • MasonryCMU     HRESULT: 0x80070057 (E_INVALIDARG)
  • Metal
  • MetalicPaint     HRESULT: 0x80070057 (E_INVALIDARG)
  • Mirror
  • PlasticVinyl     RESULT: 0x80070057 (E_INVALIDARG)
  • SolidGlass     HRESULT: 0x80070057 (E_INVALIDARG)
  • Stone
  • WallPaint     HRESULT: 0x80070057 (E_INVALIDARG)
  • Water

 

(tested with Inventor 2017.4.3)

 

 

Update: It is also not possible to create a new category in an asset library.

 

Inventor.AssetLibrary library = ...; // the asset library object (newly created and empty)
Inventor.Asset asset = ...; // the asset object (newly created in document context)

// create a new category in the library
// first parameter must be the displayname (a string value)
// second parameter must be an existing asset. API says: "An Asset that will be used as the first item in the category. The asset must exist in the same library or document as the category being created."
// => this will fail: HRESULT: 0x80004005 (E_FAIL)
Inventor.AssetCategory category = library.AppearanceAssetCategories.Add("test", asset);
0 Likes
Message 4 of 6

JarFu
Autodesk
Autodesk

Hi @thom-g,

 

Sorry about that. The API document is incorrect to describe the supported types, we will update it. The supported types should be "Ceramic", "Concrete", "Generic", "Glazing", "Wood",  "Masonry", "Metal", "Metalic Paint", "Mirror", "Plastic", "Solid Glass", "Stone", "Wall Paint", and "Water".

But in Inventor 2017.4.3, "Wood" does not work due to one API issue which was fixed in 2018.2.

 

I'll check create a new category in an asset library problem soon later.



Jar Fu
SW Engineer
Inventor QA
Autodesk, Inc.
0 Likes
Message 5 of 6

JarFu
Autodesk
Autodesk

@thom-g,

 

About <create a new category in an asset library>, please refer below VBA code.  And correct one typo in previous reply, “Metalic Paint” should be “Metallic Paint”.

 

Sub AddCategoryToLibrarytest()
    Dim oLib As AssetLibrary
    Debug.Print "AssetLibs"
    For Each oLib In ThisApplication.AssetLibraries
        Debug.Print oLib.DisplayName & "::" & oLib.InternalName & "::" & oLib.FullFileName
    Next
   
    Set oLib = ThisApplication.AssetLibraries("AFEFC330-5E61-4E24-814F-AE810148B79D")
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
   
    Dim oAss As asset
    Set oAss = oDoc.Assets.Add(kAssetTypeMaterial, "Generic", "MyMat", "MyMat")
   
    Dim oAssNew As asset
    Set oAssNew = oAss.CopyTo(oLib)
   
    Dim oCaty As AssetCategory
    Set oCaty = oLib.MaterialAssetCategories(1)
    Call oCaty.AddAsset(oAssNew)
   
    Set oCaty = Nothing
    Set oCaty = oLib.MaterialAssetCategories.Add("MyCaty", oAssNew)
End Sub



Jar Fu
SW Engineer
Inventor QA
Autodesk, Inc.
Message 6 of 6

thom-g
Advocate
Advocate

@JarFu, Thank you for your quick answers!

 

1. All of the new keywords worked (except "Wood")!

 

2. The all important clue was this line: "Set oAssNew = oAss.CopyTo(oLib)", which will first copy the asset to the library. This seems to be a must before an asset can be added to a category...

0 Likes