Profile Picture

Can anyone get this to work?

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

Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)

Group: Forum Members
Last Active: 45 minutes ago
Posts: 5.9K, Visits: 11.9K
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 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
zeronimo
zeronimo
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)

Group: Forum Members
Last Active: 22 minutes ago
Posts: 226, Visits: 10.3K
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
3 Months Ago by zeronimo
Kelleytoons
Kelleytoons
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)

Group: Forum Members
Last Active: 45 minutes ago
Posts: 5.9K, Visits: 11.9K
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 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
The-any-Key
The-any-Key
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)

Group: Forum Members
Last Active: 45 minutes ago
Posts: 267, Visits: 1.3K
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 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)Distinguished Member (19.0K reputation)

Group: Forum Members
Last Active: 45 minutes ago
Posts: 5.9K, Visits: 11.9K
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 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
Edited
3 Months Ago by Kelleytoons
The-any-Key
The-any-Key
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)

Group: Forum Members
Last Active: 45 minutes ago
Posts: 267, Visits: 1.3K
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
3 Months Ago by The-any-Key
zeronimo
zeronimo
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)

Group: Forum Members
Last Active: 22 minutes ago
Posts: 226, Visits: 10.3K


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
3 Months Ago by zeronimo
The-any-Key
The-any-Key
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)Distinguished Member (1.4K reputation)

Group: Forum Members
Last Active: 45 minutes ago
Posts: 267, Visits: 1.3K
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 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)Distinguished Member (1.5K reputation)

Group: Forum Members
Last Active: 22 minutes ago
Posts: 226, Visits: 10.3K

The-Any-Key

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

I edited my post.

thank you





Reading This Topic