Profile Picture

Avatar Opacity Setting not working

Posted By videodv 3 Months Ago
You don't have permission to rate!
Author
Message
videodv
videodv
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)

Group: Forum Members
Last Active: 43 minutes ago
Posts: 209, Visits: 4.9K
Hi

I am trying out a script to set all an avatars materials opacity settings to zero but I have come up against this error <class 'TypeError'>, File: C:\Program Files\Reallusion\iClone 7\Bin64\RLPy.py, Line: 8452
When I have seen this in the past it is pointing to not being implemented yet in the API but RL has some test code that sets the opacity so whats going on anyone have an idea?
Here is the code I am trying with Jade as a test avatar.

import RLPy

# Get Avatar mesh and Material
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
material_component = avatar.GetMaterialComponent()
mesh_list = avatar.GetMeshNames()
mesh_name = mesh_list[0]
material_list = material_component.GetMaterialNames(mesh_name)

for mesh in mesh_list:
    print("****************")
    print("Mesh List: {} ".format(mesh))
    material_list = material_component.GetMaterialNames(mesh)    
    for mat in material_list:
        print("Mat: {} ".format(mat))
        # Set Materials Invisable here NOT WORKING ??????
        material_component.AddOpacityKey(0, mesh, mat, 0)       
        print("Opacity Value: {} ".format(material_component.GetOpacity(mesh, mat))) # This works
    
print("Finished...")

This will print out the opacity setting for the correct material if you change it manually.

Chris
Kelleytoons
Kelleytoons
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)

Group: Forum Members
Last Active: 4 hours ago
Posts: 5.9K, Visits: 11.8K
Chris,

I change opacity on materials all the time, so it's most likely something wrong in your code somewhere.  I'm about ready to eat, but if Any Key doesn't beat me to it I'll post something that does work after that.



Alienware Aurora R7, Win 10, i7-8700k, 4.7GHz CPU, 32GB RAM, GTX Titan XP (12GB), Samsung 960 Pro 2TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
videodv
videodv
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)

Group: Forum Members
Last Active: 43 minutes ago
Posts: 209, Visits: 4.9K
Kelleytoons (3/31/2019)
Chris,

I change opacity on materials all the time, so it's most likely something wrong in your code somewhere.  I'm about ready to eat, but if Any Key doesn't beat me to it I'll post something that does work after that.


Hi Mike

Yup just found it forgot to add a key here is the revised code that now works.

import RLPy

# Get Avatar mesh and Material
avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
material_component = avatar.GetMaterialComponent()
mesh_list = avatar.GetMeshNames()
mesh_name = mesh_list[0]
material_list = material_component.GetMaterialNames(mesh_name)

time_line = RLPy.RGlobal_GetTime()
R_Key = RLPy.RKey()
R_Key.SetTime(RLPy.RTime(time_line))
   
for mesh in mesh_list:
    print("****************")
    print("Mesh List: {} ".format(mesh))
    material_list = material_component.GetMaterialNames(mesh)    
    for mat in material_list:
        print("Mat: {} ".format(mat))
        # Set Materials Invisable here
        material_component.AddOpacityKey(R_Key, mesh, mat, 0)       

       
print("Finished...")

Chris

Kelleytoons
Kelleytoons
Posted 2 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)Distinguished Member (18.9K reputation)

Group: Forum Members
Last Active: 4 hours ago
Posts: 5.9K, Visits: 11.8K
Ah, ya beat me to it (but for others, here's code that works for any selected object, including avatars):

import RLPy
key = RLPy.RKey()
key.SetTime(RLPy.RTime(1200))
key.SetTransitionType(RLPy.ETransitionType_Linear)
key.SetTransitionStrength(50)
opacity = 0
selected_list = RLPy.RScene.GetSelectedObjects()
for object in selected_list:
    material_component = object.GetMaterialComponent()
    mesh_list = object.GetMeshNames()
    for mesh in mesh_list:
        material_list = material_component.GetMaterialNames(mesh)
        if not material_list:
            print ("No materials in mesh")
        else:
            for matty in material_list:
                material_component.AddOpacityKey(key, mesh, matty, opacity)
                
                
print ("Finished")




Alienware Aurora R7, Win 10, i7-8700k, 4.7GHz CPU, 32GB RAM, GTX Titan XP (12GB), Samsung 960 Pro 2TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
videodv
videodv
Posted 2 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)

Group: Forum Members
Last Active: 43 minutes ago
Posts: 209, Visits: 4.9K
Thanks Mike

Ya went to make a cup of tea and it just poped into my head Blink

Thanks for the update code and enjoy your meal.

Chris.

Edited
2 Months Ago by videodv



Reading This Topic