Kars Keizer Posted August 17, 2020 Share Posted August 17, 2020 (edited) I'm writing an Python script with this part in it: vs.DoMenuTextByName('Standard Views',8) vs.DoMenuTextByName('Fit To Objects', 0) vs.SetLayerRenderMode(_hRenderlayer, 6, True, True) Now i have the problem that the script gives the order to set the view and zoom and VectorWorks will do this , but when the script is ordering to set the rendermode VW is still busy setting the zoom and view and will skip this step. If i run this script again without changing my zoom and view it will set the render mode correct because then VW can skip zoom and view and is ready when it gets the order to change the rendermode. I Think the issue is probably that VW is visually showing the zoom an view change and that takes time. To set the rendermode first is not working because it will change back to wireframe when the zoom/view is changed. I also tried the function vs.Wait() but this is not making any difference except the script takes longer to run. Has someone an idea to overcome this? Edited August 17, 2020 by Kars Keizer Quote Link to comment
MullinRJ Posted August 17, 2020 Share Posted August 17, 2020 Hello Kars (@Kars Keizer), I'm not to sure this is related, but it is confusing. From the Script Reference Appendix I get: and 6 appears to be "Final Shaded". When I run your script I get "Hidden Line", as read from the VW View>Rendering menu. I tried different constants and 5 gave me "Final Shaded Polygon", again as read from the VW View>Rendering menu. On a whim, try different constants. It may or may not work as it may also be platform dependent. I am on a MAC and you are on a PC. It's worth a try. If you find the numbers are wrong, you may have found a bug in the documentation. Raymond Quote Link to comment
Kars Keizer Posted August 17, 2020 Author Share Posted August 17, 2020 @MullinRJ I see, when I wrote the code i saw this comment in the remarks Following this remark i got this list of constants which i noticed were correct. so the list in the appendix is not correct I think. But this is not what is causing the problem. Quote Link to comment
Kars Keizer Posted August 19, 2020 Author Share Posted August 19, 2020 (edited) 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 can not be 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 August 19, 2020 by Kars Keizer Quote Link to comment
Recommended Posts
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.