Announcement

Collapse
No announcement yet.

VRayPlane doesn't render when created with python

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VRayPlane doesn't render when created with python

    Hello,

    V-ray Next for Maya 2018 user here.

    I've run into a problem with a python script that creates a VRayPlane. It doesn't render simply because when creating the object through python, it does not create the attribute "instObjGroups" which usually gets assigned to the "dagSetMembers" of the initialShadingGroup. If manually created by going to the tab: V-Ray > Geometry > V-Ray Plane, it all works fine and the shape node is properly created with the "instObjGroups" attribute connected.

    -Why is this attribute not created by default when using python to create the VrayPlane transform node and VrayPlane shape node, should it not be exactly the same??

    I remember it wasnt the same for lights, In order to use them properly you have to create them using the 'cmds.shadingNode( asLight=True )' command rather than 'cmds.createNode()', so perhaps this is where I am going wrong however I cannot find any possible way as of yet to get this to work.

    cmds.createNode( 'VRayPlane', name='VRayPlaneShape' )

    The above snip creates a transform node called "VRayPlane" with the shape node as a child call "VRayPlaneShape"
    When comparing this side by side in the node editor with a vray plane created from the menu, they are exactly the same except the python one is missing the attribute I need and thus I cannot assign a shader to it manually or automatically.

    What am I doing wrong here and how can I create the default VrayPlane in python and get it to render?

    Thanks and apologies for my nubbish python.


  • #2
    Hello!
    The VRayPlane is not rendered because there is no shading group connected to it and the attribute "instObjGroups" is there but not connected. The code you have written only creates the plane. You need to assign a material, for example VRayMtl
    or you can add the plane to the initiaShadingGroup using the following extended version of you code snippet:
    cmds.createNode( 'VRayPlane', name='VRayPlaneShape')
    cmds.sets(e=True, forceElement='initialShadingGroup')

    Best regards,
    Iliyana Vladeva
    Iliyana Vladeva
    Software Development Engineer
    V-Ray for Maya

    Comment


    • #3
      Hello! Thank you for your response. But I still found your example "cmds.sets(e=True, forceElement='initialShadingGroup')" not to work.
      Originally posted by iliyana.vladeva View Post
      The VRayPlane is not rendered because there is no shading group connected to it and the attribute "instObjGroups" is there but not connected.
      Yes I understand there is no shading group initially connected, even assigning a VRayMtl from the hypershade would still not render. The VRayPlaneShape will accept the material without error, however does not actually connect the shape to the shading group. I have tried both from python and from the hypershade to assign it a material. I found the following will connect the shape to the shading group, but still when I go to render there is nothing:

      cmds.createNode( 'VRayPlane', name='VRayPlaneShape' )
      cmds.connectAttr( 'VRayPlaneShape.instObjGroups[0]', 'initialShadingGroup.dagSetMembers[2]', na=True )

      and your example does the same thing but more simple (thank you!):

      cmds.createNode( 'VRayPlane', name='VRayPlaneShape')
      cmds.sets(e=True, forceElement='initialShadingGroup')

      Here is what I am doing:

      1) open a blank scene in maya, create a light and a sphere or just some object in general so that you can see something (if you prefer, I do)

      2) create a vray plane from the menus in maya

      3) render it, you will see the plane

      4) delete the plane, go to script editor and try this:

      import maya.cmds as cmds
      cmds.createNode( 'VRayPlane', name='VRayPlaneShape' )
      cmds.connectAttr( 'VRayPlaneShape.instObjGroups[0]', 'initialShadingGroup.dagSetMembers[2]', na=True )

      5)notice no errors, just a simple warning about the next available set to ignore, the vray plane gets created as expected, and you can check that the shape is connected to the shading group properly. everything should be fine... render it, you will see no vray plane being rendered (at least I am not seeing it)

      6)delete the plane, go to script editor and try this:

      import maya.cmds as cmds
      cmds.createNode( 'VRayPlane', name='VRayPlaneShape' )
      cmds.sets(e=True, forceElement='initialShadingGroup')

      7) same thing as in step 5. no errors, everything connected properly, but still does not show up in the render.

      There has got to be another attribute somewhere that I cannot find to get this to render properly.

      Edit: noob question, what exactly does "e=True" mean? I didn't see anything in the Maya Python index that shows this parameter. Does it mean empty set?
      Last edited by Harrison W; 10-10-2019, 02:27 PM.

      Comment


      • #4
        Hello again!

        My guess is that you don't see the V-Ray Plane because of inappropriate view angle and you need to rotate the camera a bit.
        I hope the video will help you understand what I mean.

        The code that I sent you is what we currently use. The only additional thing is that we rotate the plane.
        "e=True" stands for editing mode.

        If you want, you can directly use the MEL function we use to create the V-Ray Plane.
        It might be subject to change, so use it at your will.
        You can call it in python this way:
        maya.mel.eval('vrayCreatePlane')
        Iliyana Vladeva
        Software Development Engineer
        V-Ray for Maya

        Comment


        • #5
          Thank you for the video. But it seems maybe I need to try reinstalling maya and vray at this point because it is still not working for me. Moving the camera around doesn't make a difference for me, the plane really will not show up for some reason. The only way I can get the plane to render is by creating it through the menus
          Thank you kindly for taking the time to help me.

          Comment


          • #6
            I have an update. I got it to work after trying a different Nvidia driver for my GPU. The entire time I was ignoring a CUDA version error (because it has never caused an issue before and everything was working fine except for the vray plane not rendering). Since I have been rendering on GPU only for a while now, I didn't even think to see if it worked on the CPU only. So now I feel silly but everything is working as expected on the GPU.
            Thanks again, much appreciated!
            Last edited by Harrison W; 16-10-2019, 07:22 PM.

            Comment

            Working...
            X