Maya 2015 API set default for MPxSurfaceShape attributes

Maya 2015 API set default for MPxSurfaceShape attributes

haggi_master
Advocate Advocate
740 Views
4 Replies
Message 1 of 5

Maya 2015 API set default for MPxSurfaceShape attributes

haggi_master
Advocate
Advocate

Hi,

I have my own surface shape which inherits from MPxSurfaceShape. Unfortunately the default values for "visible in reflection" and "visible in refraction" is off. That mans I have to turn it on everytime I create a new node of this type. But it is a possible source of problems.

 

Is there a way to change the default values of these attributes? Or do I have to wrap my node into a creation script which sets the correct attributes?

0 Likes
Accepted solutions (1)
741 Views
4 Replies
Replies (4)
Message 2 of 5

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I think you could try postConstructor.

 

Yours,

Li

0 Likes
Message 3 of 5

haggi_master
Advocate
Advocate

What I already tried is to set the plugs to "true" in the postConstructor. But that happens always if a node is created, what means if I turn it off for some reason they are turned on the next time I load the scene.

0 Likes
Message 4 of 5

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

I've just got an idea about this. Use MFileIO to check if it is opening a scene.

 

 

	if (!(MFileIO::isImportingFile() |
		MFileIO::isOpeningFile() |
		MFileIO::isReferencingFile() |
		MFileIO::isReadingFile())
		)
	{
		MFnDependencyNode fnNode(thisMObject());
		auto plug = fnNode.findPlug("visibleInRefractions");
		plug.setBool(true);
	}

I've tested myself, it seems fine.

 

 

Yours,

Li

0 Likes
Message 5 of 5

haggi_master
Advocate
Advocate

Yepp, seems to work fine. Great idea, thank a lot.

0 Likes