How to Apply Texture Box Mapping to SurfaceBody

How to Apply Texture Box Mapping to SurfaceBody

AnJanson
Advocate Advocate
827 Views
5 Replies
Message 1 of 6

How to Apply Texture Box Mapping to SurfaceBody

AnJanson
Advocate
Advocate

Hi,

I would like to adjust the texture appearence mapping to box. Is it possible with the API?

The manual steps are:

1. Select a surfacebody

2. Apply an appearence

3. Adjust the the texture mapping to box (Tools tab -> Materials and Appearances panel -> Adjust -> Texture Mapping)

Thanks

Andreas

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

YuhanZhang
Autodesk
Autodesk

You can refer to the API help below to get familiar with how to edit the appearance Asset API, there are code samples to print the Asset info(AssetValue) so you can find which AssetValue is what you need to adjust the appearance texture:

 

http://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-9CD3F311-E5BD-4151-8EF9-8E9806A02609



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 6

AnJanson
Advocate
Advocate

Thanks for the hint. Maybe I missed it, but unfortunately none of the examples include an approach to material mapping. I had looked at the examples before.

0 Likes
Message 4 of 6

YuhanZhang
Autodesk
Autodesk

Here is a VBA code sample, you can new a part and create a block in it, then run below VBA code to check how it changes the appearance asset:

 

Sub ChangeAppearanceAssetSampleCode()
    Dim oAssetLib As AssetLibrary
    Set oAssetLib = ThisApplication.AssetLibraries.Item("AFEFC330-5E61-4E24-814F-AE810148B79D") 'Inventor Material Library
     
    ' create a part and a block in it firstly.
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    ' get an appearance asset from library.
    Dim oLibAsset As Asset
    Set oLibAsset = oAssetLib.AppearanceAssets.Item("1in Squares - Mosaic Blue")
    
    ' copy the library asset to document.
    Dim oDocAsset As Asset
    Set oDocAsset = oLibAsset.CopyTo(oDoc, True)
    
    ' assign the appearane to the document.
    oDoc.ActiveAppearance = oDocAsset
    
    Stop ' pause here to check the current appearance
    
    Dim oAsset As Asset
    Set oAsset = oDoc.ActiveAppearance
    Debug.Print oAsset.DisplayName
    
    ' get the texture asset value
    Dim oTextureAssetValue  As TextureAssetValue
    Dim oTextureAsset  As AssetTexture

    Set oTextureAssetValue = oAsset.Item("ceramic_pattern_map")
    Set oTextureAsset = oTextureAssetValue.Value
    'oTextureAsset.Item("texture_WAngle").Value = 45  ' rotate
    oTextureAsset.Item("texture_RealWorldScaleX").Value = 10
    oTextureAsset.Item("texture_UScale").Value = 10 ' scale
 
End Sub


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 6

AnJanson
Advocate
Advocate

Thanks @YuhanZhang for your input.

That could help me a little bit, but it does not solve the problem finally.

My final goal is to represent wood as realistically and diversely as possible.

With your approach I was able to adjust the rotation and scaling variably, thank you for that.

Unfortunately, that doesn't solve the mapping problem. Do you have any ideas how I can change that?

For example the year rings should be rotated around 90 degrees.

AnJanson_0-1601206524213.png

 

0 Likes
Message 6 of 6

YuhanZhang
Autodesk
Autodesk

In the sample I commented a line, you can uncomment it and try if it works for you. You can change the value to 90 which indicates 90 degree:

 

oTextureAsset.Item("texture_WAngle").Value = 45

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes