Rotate Texture

Rotate Texture

robmatthews
Collaborator Collaborator
1,226 Views
5 Replies
Message 1 of 6

Rotate Texture

robmatthews
Collaborator
Collaborator

We use a lot of #4 finish Stainless steel sheet.

 

I have automated the changing of the active renderstyle to "Polished Brushed" to approximate this, but usually orientation is important. For instance, the texture will be around tube, and on large sheets, we want to keep all the sections orientated one specific direction.

 

I'd like to be able to easily rotate the texture thru 90 degrees (and possibly, a user selectable angle).

 

I'd prefer not to have to manually select a face first, either. 

 

Is this possible?

 

 

=============================================
This is my signature, not part of my post.
0 Likes
1,227 Views
5 Replies
Replies (5)
Message 2 of 6

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

Have you tried with RenderStyle.TextureRotation ? It gets and sets the rotation of the texture. The angle is defined in radians.

 

As to selecting face by program, you have two choices:

 

- Use CommandManager.Pick to ask the user to select an object. e.g. the code below asks to select a feature.

  

Public Sub GetSingleSelection()
    ' Get a feature selection from the user
    Dim oObject As Object
    Set oObject = ThisApplication.CommandManager.Pick(kPartFeatureFilter, "Pick a feature")

    MsgBox "Picked: " & oObject.Name
End Sub

- Use InteractionEvents to start a selecting event, waiting for user's selecting. Please refer to chapter [InteractionEvents ] in API help document.

0 Likes
Message 3 of 6

ekinsb
Alumni
Alumni

I don't think it's good to edit an existing appearance asset because it will change everything that uses that asset.  I think the best solution in this case is to create a copy of the "Polished Brush" asset and edit the copy so that the rotation is 90 deg. from the original.  Now you can just swap between the two assets to change the orientation of the texture.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 4 of 6

robmatthews
Collaborator
Collaborator

Hi. I got this working, but then lost the ivb file, unfortunately. We're jumping up (!) to 2016, and I'm trying to get it going again.  What I have is not working, and I can't figure out why...

 

Please help?

 

Sub Rotate_Texture()
Dim oDoc As PartDocument
If ThisApplication.ActiveDocument.DocumentType = kPartDocumentObject Then
    Set oDoc = ThisApplication.ActiveDocument
    If oDoc.ActiveRenderStyle.TextureRotation < 1 Then
        oDoc.ActiveRenderStyle.TextureRotation = 90
    Else
        oDoc.ActiveRenderStyle.TextureRotation = 0
    End If
    oDoc.Update
End If
Set oDoc = Nothing
End Sub
=============================================
This is my signature, not part of my post.
0 Likes
Message 5 of 6

dg2405
Advocate
Advocate

As xiaodong described, the angle shuld be radian.

This code switches my texture from 0 to 90 or back:

Sub Rotate_Texture()
Dim oDoc As PartDocument
If ThisApplication.ActiveDocument.DocumentType = kPartDocumentObject Then
    Set oDoc = ThisApplication.ActiveDocument
    If oDoc.ActiveRenderStyle.TextureRotation <> 0 Then
        oDoc.ActiveRenderStyle.TextureRotation = 0
    Else
        oDoc.ActiveRenderStyle.TextureRotation = 2 * Atn(1)
    End If
    oDoc.Update
End If
Set oDoc = Nothing
End Sub
0 Likes
Message 6 of 6

robmatthews
Collaborator
Collaborator

Thank you for your response, but that still doesn't actually change the displayed appearance.

=============================================
This is my signature, not part of my post.
0 Likes