Jump to content
Kars Keizer

zoom and rendermode in script too fast/slow

Recommended Posts

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 by Kars Keizer

Share this post

Link to post

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.




Share this post

Link to post


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.

Share this post

Link to post

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)

_dRenderlayer=vs.CreateLayer(_dLayername, 1)
_pLayername=vs.CreateLayer(_pLayername, 2)
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.SetObjectVariableInt(_hViewport1, 1001, 11)#Renderstyle OpenGL
vs.Ungroup(vs.SymbolToGroup(_hViewport1, 0))
_hImage = vs.LSActLayer()
_ImageType = vs.GetObjectVariableLongInt(_hImage, 532)
if _ImageType == 1:
	ext = '.jpg'
	ext = '.png'
_fileName = _RenderFolder +'\\' + _nSymbol + ext
vs.ExportImageFile(_hImage, _fileName)


Edited by Kars Keizer

Share this post

Link to post

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.

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.


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...