Disclaimer:
This is a crosspost from 3DSwym but lately I feel that I cannot get any help there anymore. This forum seems more appropriate and I appreciate the structure greatly.
I was trying to build a macro that changes the texture angle by 90degrees. This is to visualize the wood grain properly (final goal would be to align the grain with a coordinate system that we put in.
Sub main()
Dim swApp As SldWorks.SldWorks
Dim myModel As SldWorks.ModelDoc2
Dim myPart As SldWorks.PartDoc
Dim myMatVisProps As SldWorks.MaterialVisualPropertiesData
Dim configName As String, databaseName As String
Dim orgAngle As Double
Dim longstatus As Long
Set swApp = Application.SldWorks
Set myModel = swApp.ActiveDoc
Set myPart = myModel
Set myMatVisProps = myPart.GetMaterialVisualProperties()
If Not myMatVisProps Is Nothing Then
orgAngle = myMatVisProps.Angle
orgAngle = orgAngle + 1.57#
myMatVisProps.Angle = orgAngle
longstatus = myPart.SetMaterialVisualProperties(myMatVisProps, 2, Nothing)
End If
End Sub
After applying longstatus
the appearance looses the image path and it only shows a blank part without the texture applied.
Any idea why this happens? (I’m on SolidWorks 2017)
Any idea how to solve this?
Edit:
Thank you for creating a forum that has a great structure and gathers the most famous programmers regarding SolidWorks.