When loading the script as a plugin, the API findMaterial() occurres an error: NameError: name 'findMaterial' is not defined

When loading the script as a plugin, the API findMaterial() occurres an error: NameError: name 'findMaterial' is not defined

zhujianchen
Contributor Contributor
773 Views
3 Replies
Message 1 of 4

When loading the script as a plugin, the API findMaterial() occurres an error: NameError: name 'findMaterial' is not defined

zhujianchen
Contributor
Contributor

Hi,Guys.

When loading the script as a plugin, the API findMaterial() occurres an error : NameError: name 'findMaterial' is not defined.

Can anyone help me solve this problem?

mat = findMaterial("material_name")

Traceback (most recent call last):

          File "<string>", line 38, in Material_change

NameError: name 'findMaterial' is not defined

 

thanks a lot.

0 Likes
Accepted solutions (2)
774 Views
3 Replies
Replies (3)
Message 2 of 4

Christian_Garimberti
Advisor
Advisor
Accepted solution

You have use V2 API's, so just add vrMaterialService. before findMaterial()

so vrMaterialService.findMaterial("material_name")

 

Best

Chris

 

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes
Message 3 of 4

zhujianchen
Contributor
Contributor

Hi, Chris.

First of all, thank you for your reply. I have already tried what your said. But it also report an error(Vred2022). Do you konw what's is wrong?

temp_mat = vrMaterialService.findMaterial("material_name")

 

Traceback (most recent call last):

      File "<string>", line 37, in material_change

NameError: name 'vrMaterialService' is not defined

0 Likes
Message 4 of 4

zhujianchen
Contributor
Contributor
Accepted solution

I have found the reason of error. when i use another vision of vred(like vred 2022.3), it'll be fine.

0 Likes