Howdy,
I work for a small Coaxial cable design house, and I'm trying to automate the creation of product renderings.
I've hit a wall though. I have code that generate a series of cylinders and applies a material to them. And I've found code to place the camera and render the scene.
The last piece of the puzzle is how to apply bump maps or displacement maps to the surfaces. Some layers of the cable are taped, or woven and I would like to be able to add those textures onto the cable.
I can do it manually, and it looks great. But when I try to record a macro, the macro doesn't record anything.
I found this example code for Solidworks 2016, but when I run it the texture is not applied to the part. It still has it's default.
2016 SOLIDWORKS API Help - Get Surface-finish Image Path and File Name Example (VBA)
I'm sure I'm missing something like a library or quirk with solidworks api. Below is the loop where I assign each body a material. I was hoping I could apply a bump map or displacement map the same way.
Thank you.
Dim swBody As SldWorks.Body2, Bodies As Variant, itr As Long, boolstat As Boolean
Dim Material As String
Bodies = Part.GetBodies2(swAllBodies, False)
For itr = 0 To UBound(Bodies)
Set swBody = Bodies(itr)
boolstat = swBody.Select2(False, Nothing)
BodyMaterialError = swBody.SetMaterialProperty("Default", "solidworks materials.sldmat", "ABS PC")
' Trying to apply the texture here
BodyMaterialError = swBody.BumpTextureFilename("C:\Testing.png")
Next itr