Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why sometimes different from PyMaterialX #157

Closed
ArthurChiu opened this issue Oct 30, 2018 · 4 comments
Closed

why sometimes different from PyMaterialX #157

ArthurChiu opened this issue Oct 30, 2018 · 4 comments

Comments

@ArthurChiu
Copy link

use codeexamples :
import MaterialX as mx

Create a document.

doc = mx.createDocument()

Create a node graph with a single image node and output.

nodeGraph = doc.addNodeGraph()
image = nodeGraph.addNode('image')
image.setParameterValue('file', 'image1.tif', 'filename')
output = nodeGraph.addOutput()
output.setConnectedNode(image)

Create a simple shader interface.

shader = doc.addNodeDef('shader1', 'surfaceshader', 'simpleSrf')
diffColor = shader.setInputValue('diffColor', mx.Color3(1.0))
specColor = shader.setInputValue('specColor', mx.Color3(0.0))
roughness = shader.setParameterValue('roughness', 0.25)

Create a material that instantiates the shader.

material = doc.addMaterial()
shaderRef = material.addShaderRef('shaderRef1', 'simpleSrf')

Bind roughness to a new value within this material.

bindParam = shaderRef.addBindParam('roughness')
bindParam.setValue(0.5)

Display the value of roughness in the context of this material.

print str(roughness.getBoundValue(material))

the code "image = nodeGraph.addNode('image')" can't run
mistake will be display "'PyMaterialX.NodeGraph' object has no attribute 'addNode'"? why? thankes for you reply!

@jstone-lucasfilm
Copy link
Member

Hi Arthur,

Are you sure that you're working with a complete build of MaterialX Python? There are calls to NodeGraph.addNode in our Python test suite, for example, which runs as part of the continuous integration process for the MaterialX library:

https://github.com/materialx/MaterialX/blob/master/python/MaterialXTest/main.py#L189

If you build MaterialX Python through CMake, and install the resulting Python package to your Python environment, you should see a collection of Python wrappers such as main.py and datatype.py in the distribution, and not just the raw PyMaterialX shared library.

Full build instructions can be found here, and let us know if we can clarify any of the steps:

http://www.materialx.org/docs/api/index.html

All the best,

-Jonathan

meshula pushed a commit to meshula/MaterialX that referenced this issue Nov 3, 2018
@ArthurChiu
Copy link
Author

this is my cmake command
cmake -G "Visual Studio 14 2015 Win64" -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_DOCS=ON ..\MaterialX-master
have any questions?

@jstone-lucasfilm
Copy link
Member

Hi Arthur,

Could it be that you're building MaterialX with the command above, but never installing the MaterialX Python package to a destination folder? In our online test suite, for example, we build and install MaterialX with the following command:

  • cmake --build . --target install

In the Appveyor/Windows test suite, this installs MaterialX Python to the "site-packages" folder of the Python installation, and in the Travis/Linux test suite, it installs MaterialX Python to a local folder for testing.

-Jonathan

@jstone-lucasfilm
Copy link
Member

Hi Arthur,

I'm going to close out this issue for now, and feel free to follow up on the MaterialX Discussion Forum if you have additional build questions:

https://groups.google.com/forum/#!forum/materialx

All the best,

-Jonathan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants