Jump to content

Exporting Renders/Images to folder


Recommended Posts

I'm writing an script that will take each symbol(_i in list of symbols) from the resource folder makes an render and places it in an folder.

for _i in _lSymbols:
	_Renderlayer=vs.Layer('Render')
	_hRenderlayer=vs.ActLayer()
	vs.Symbol(_i,0,0,0)
	vs.DoMenuTextByName('Standard Views',8)
	vs.DoMenuTextByName('Fit To Objects', 0)
	vs.SetLayerRenderMode(_hRenderlayer, 6, True, True)
	vs.DoMenuTextByName('Copy',0)
	vs.DeleteObjs()
	vs.DoMenuTextByName('Paste As Picture',0)
	_hImage=vs.LNewObj()
	_iRenderFolder=_RenderFolder+ '\\' +_i+'.png'
	vs.ExportImageFile(_hImage,_iRenderFolder)
	vs.DeleteObjs()

One problem i encountered is that when i set the render mode as "Final Quality Renderworks" (14) or "openGL" (11) it will produce an white square with "paste as picture".
so whit this script I'm limited to using modes as "FinalHiddenLine"(6)

 

Also my "vs.ExportImageFile" is not working at the moment.

 

 

Can Anyone give some tip ore advise on this script or how the get an similar result using other functions.
I also looked into using vs.DoMenuTextByName('Export Image File') but this wil give an dialog for the user and I'm trying to limit/eliminate all user interaction.

 

 

See also my other topic on an small part of this script

 

Edited by Kars Keizer
Link to comment

  

Got what i wanted by first making an viewport and then exporting this viewport as an image,

By doing it this way i can use every render style and it will have no problems updating

The two time changing the render style and updating is because other wise the viewport will show an red cross. (don't no why but is working now)

_dLayername='Render'
_pLayername='Render2'
_dRenderlayer=vs.CreateLayer(_dLayername, 1)
_pLayername=vs.CreateLayer(_pLayername, 2)
_hViewport1=vs.CreateVP(_pLayername)
_nClass=vs.ActiveClass()
vs.SetObjectVariableInt(_hViewport1, 1001, 0)#Renderstyle Wireframe
vs.SetVPLayerVisibility(_hViewport1, _dRenderlayer, 0)#set Layer visible in VP
vs.SetVPClassVisibility(_hViewport1, _nClass, 0)#set class visible in VP
vs.SetObjectVariableInt(_hViewport1, 1000, 0)#Orthogonaal
vs.SetObjectVariableInt(_hViewport1, 1007, 9)#view
vs.UpdateVP(_hViewport1)
vs.SetObjectVariableInt(_hViewport1, 1001, 11)#Renderstyle OpenGL
vs.UpdateVP(_hViewport1)
vs.Ungroup(vs.SymbolToGroup(_hViewport1, 0))
_hImage = vs.LSActLayer()
_ImageType = vs.GetObjectVariableLongInt(_hImage, 532)
if _ImageType == 1:
	ext = '.jpg'
else:
	ext = '.png'
_fileName = _RenderFolder +'\\' + _nSymbol + ext
vs.ExportImageFile(_hImage, _fileName)
_hlayer1=vs.FLayer()
_nlayer1=vs.GetLName(_hlayer1)
vs.Layer(_nlayer1)
_hRenderlayer=vs.GetLayerByName(_dLayername)
vs.DelObject(_hRenderlayer)	
_hRenderlayer=vs.GetLayerByName(_pLayername)
vs.DelObject(_hRenderlayer)	

 

Edited by Kars Keizer
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...