I want to render the Model/object in window

I want to render the Model/object in window

Anonymous
Not applicable
652 Views
4 Replies
Message 1 of 5

I want to render the Model/object in window

Anonymous
Not applicable

Hi,

I want to render the object in window.

I've created a window in Maya using python scripting. And I've a model in Maya which is in '.obj' format.

Now I want to show the object in the window I created through scripting. How should I go about this?

I searching up & down on the Maya document where I'm unable to find a proper solution.

Please provide a solution. Even if the solution is bit complicated I'm ready to work with it.

0 Likes
653 Views
4 Replies
Replies (4)
Message 2 of 5

rajasekaransurjen
Collaborator
Collaborator

Hi,

Do you want to show the image of the Obj or Like a panel window.....can you share your window script.

0 Likes
Message 3 of 5

Anonymous
Not applicable
Not a static image I need to render a model same as Panel
0 Likes
Message 4 of 5

rajasekaransurjen
Collaborator
Collaborator

Hi,

Try this.....

select the object and the script.

import maya.cmds as cmds
window = cmds.window(widthHeight=(500, 500))
cmds.paneLayout()
rsSelObj = cmds.ls( sl=True )
rsObjPos = cmds.xform(rsSelObj, q=True, ws=True, t=True)
rsCameraName = cmds.camera()
cmds.modelPanel(cam = rsCameraName[0])
rsCamShape = rsCameraName[1]
rsBBox = cmds.exactWorldBoundingBox(rsSelObj)
cmds.move( (rsBBox[0]/rsBBox[3]), (rsBBox[1]/rsBBox[4]), (rsBBox[2]/rsBBox[5]), rsCameraName, absolute=True )
cmds.viewPlace( rsCamShape, la=(rsObjPos[0], rsObjPos[1], rsObjPos[2]) )
cmds.showWindow( window )
0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks for the replay.

Your code was useful. But not exactly what I was searching.

I have found an alternative but I'm not sure if this proper way if I have a desktop application as my end product.

 

import maya.cmds as cmds

cmds.window()
cmds.file(Demo.obj, r=True)
cmds.render(replace=True)
if cmds.paneLayout('demoModel', exists=True):
    cmds.deleteUI('demoModel', panel=True)

cmds.paneLayout( 'demoModel', width=800, height=600 )
form = cmds.formLayout()
editor = cmds.modelEditor('demoModelEditor')
column = cmds.columnLayout('true')
cmds.formLayout( form, edit=True, attachForm=[(column, 'top', 0), (column, 'left', 0), (editor, 'top', 0), (editor, 'bottom', 0), (editor, 'right', 0)], attachNone=[(column, 'bottom'), (column, 'right')], attachControl=(editor, 'left', 0, column))

cmds.modelEditor( editor , edit=True, rom='myOverride', displayAppearance='smoothShaded', backfaceCulling=True)
cmds.showWindow()

If you can suggest me with any alternatives to cmds.file() it is much appreciated.

0 Likes