Profile Picture

Can anyone get this to work?

Posted By Kelleytoons 5 Years Ago
You don't have permission to rate!
Author
Message
Kelleytoons
Kelleytoons
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)

Group: Forum Members
Last Active: 4 minutes ago
Posts: 9.1K, Visits: 21.8K
So with the newest release (which gives us "Selected") I thought I'd get back to some odds and ends I needed to clean up.  However, I'm running into several errors and it might just be I've been away from Python for too long (even a few weeks of me doing other programming - Lua - can turn my brain into mush).

Here's my code:

import RLPy
selected_list = RLPY.RScene.GetSelectedObjects()
# object = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "nys_store_1")
for object in selected_list:
    material_component = object.GetMaterialComponent()
    mesh_list = object.GetMeshNames()
    for mesh in mesh_list():
        print (mesh.name)
        material_list = material_component.GetMaterialNames(mesh)
        if len(material_list) == 0:
            print ("No materials in mesh")
        else:
            for matty in material_list:
                print (matty)
            
 I get an name error right away on GetSelectedObjects, although that appears to be the right syntax (I wish they hadn't taxed that).  When I try and blow by that (by hardcoding an object, which is the commented line -- I uncomment it and comment out the for loop) I get an name error on GetMaterialComponent, a function which worked fine for me before (Note: these errors are NOT caused by what exists in a scene, but rather indicate these functions do not exist, or are not called correctly).

I guess I have two questions:

1) Is my code correct and, if not, what is the correct code?
2) Does any of this work for anyone else?  If so, then perhaps I've got to reinstall iClone and the Python dev version. 




Alienware Aurora R12, Win 10, i9-119000KF, 3.5GHz CPU, 128GB RAM, RTX 3090 (24GB), Samsung 960 Pro 4TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
Zeronimo
Zeronimo
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)

Group: Forum Members
Last Active: 12 hours ago
Posts: 478, Visits: 19.1K
exactly the same for me, I have an error on this instruction.
it seems that the syntax is correct and conforms to the doc.
This must be part of the instructions being developed.
The ball is in RL's camp.

Edit : it would be nice if we could have an updated version of the python API being developed.
Edited
5 Years Ago by zeronimo
Kelleytoons
Kelleytoons
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)

Group: Forum Members
Last Active: 4 minutes ago
Posts: 9.1K, Visits: 21.8K
Thanks for the confirmation -- I have written to Luke but he must be busy right now as I haven't heard from him in a while.

Sigh.



Alienware Aurora R12, Win 10, i9-119000KF, 3.5GHz CPU, 128GB RAM, RTX 3090 (24GB), Samsung 960 Pro 4TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
The-any-Key
The-any-Key
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)

Group: Forum Members
Last Active: 2 Weeks Ago
Posts: 356, Visits: 1.9K
Try replace:
selected_list = RLPY.RScene.GetSelectedObjects()
With:
selected_list = RLPy.RScene.GetSelectedObjects()



iClone 7, 3DXchange 7 Pipeline, CC3 Pipeline, CT8 Pipeline, Iray, Live Face, iPhone Xr, Win 10, i9 9900K ~5GHz, Nvidia RTX 2080 8GB, 16GB Ram, M.2 SSD
Kelleytoons
Kelleytoons
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)Distinguished Member (35.6K reputation)

Group: Forum Members
Last Active: 4 minutes ago
Posts: 9.1K, Visits: 21.8K
Crap -- didn't see that.

Thanks for the syntax catch -- but does the REST of it work for you?  IOW, can you get GetMaterial to work?  (Because I used to be able to do so and I can't, not even when I comment out all the Selected() stuff and just use a named Object).



Alienware Aurora R12, Win 10, i9-119000KF, 3.5GHz CPU, 128GB RAM, RTX 3090 (24GB), Samsung 960 Pro 4TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
Edited
5 Years Ago by Kelleytoons
The-any-Key
The-any-Key
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)

Group: Forum Members
Last Active: 2 Weeks Ago
Posts: 356, Visits: 1.9K
With some modifications it works fine:
selected_list = RLPy.RScene.GetSelectedObjects()
# object = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "nys_store_1")
for object in selected_list:
material_component = object.GetMaterialComponent()
mesh_list = object.GetMeshNames()
for mesh in mesh_list:
print (mesh)
material_tuple = material_component.GetMaterialNames(mesh)
# Check if got tuple
if not material_tuple:
print ("No materials in mesh")
else:
for matty in material_tuple:
print (matty)




iClone 7, 3DXchange 7 Pipeline, CC3 Pipeline, CT8 Pipeline, Iray, Live Face, iPhone Xr, Win 10, i9 9900K ~5GHz, Nvidia RTX 2080 8GB, 16GB Ram, M.2 SSD
Edited
5 Years Ago by The-any-Key
Zeronimo
Zeronimo
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)

Group: Forum Members
Last Active: 12 hours ago
Posts: 478, Visits: 19.1K


with the changes made by The-Any-Key the REST also works.

import RLPy

#selected_list = RLPy.RScene.GetSelectedObjects()

object = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Arches")

# for object in selected_list:

material_component = object.GetMaterialComponent()
mesh_list = object.GetMeshNames()

for mesh in mesh_list:
    print (mesh)
    material_tuple = material_component.GetMaterialNames(mesh)
    if not material_tuple:  
        print ("No materials in mesh")
  else:
        for matty in material_tuple:
            print (matty)

When I made the first attempt, I did a copy and paste of the script and I did not pay attention to the RPLY instead of the RPLy, usually I program in Delphi which does not make the difference between capital letters and tiny.

Congratulations to the lynx eye of The-Any-Key.



Edited
5 Years Ago by zeronimo
The-any-Key
The-any-Key
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)

Group: Forum Members
Last Active: 2 Weeks Ago
Posts: 356, Visits: 1.9K
zeronimo

Replace:
        for matty in material_tuple:
        print (Matty)
with:
        for matty in material_tuple:
        print (matty)




iClone 7, 3DXchange 7 Pipeline, CC3 Pipeline, CT8 Pipeline, Iray, Live Face, iPhone Xr, Win 10, i9 9900K ~5GHz, Nvidia RTX 2080 8GB, 16GB Ram, M.2 SSD
Zeronimo
Zeronimo
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)

Group: Forum Members
Last Active: 12 hours ago
Posts: 478, Visits: 19.1K

The-Any-Key

I saw, it is an error that I made during the copying.

I edited my post.

thank you





Reading This Topic