API - Import Material Using Ruby Console

Hi guys, I’m studying the new V-Ray for SketchUp API and creating a plugin to add my materials, but I couldn’t import it using the parameter.

scene.import(‘C:/User/Download/brick.vrmat’, as_is: true)

I’m new in this area and I don’t know if I need to use some module or definition to make it work. I appreciate the help.

Thanks :slight_smile:

Hi henriqueb ,

For some script operations you have to call VRay::refresh_ui at the end of the script.
This way the Asset Editor will refresh and show the new scene content.

You can try the following:


scene= VRay::Context.active.scene
scene.import('C:/User/Download/brick.vrmat', as_is: true)
VRay::refresh_ui

Regards,
Konstantin

Thank you so much Konstantin, it worked correctly, but VRayMtl doesn’t open and the textures don’t load, do you have any tips? Thanks

Hi henriqueb ,

I’ve consulted with the devs about this and there seems to be a better way to write this script:


scene = VRay::Context.active.scene
scene.change { scene.import('C:/User/Download/brick.vrmat') }

If it still fails, please share some more detailed information on what you do and what the end result is.
You can share the material you’re testing with as well.

Konstantin

Many Thanks Konstantin, it worked perfectly. :slight_smile:

Best regards