Markus Barrera-Kolb Posted January 23, 2018 Share Posted January 23, 2018 I'm trying to write a script using DoMenuTextByName in order to switch to a normal perspective and OpenGL. This is because VW seems to ignore the default render mode and projection when I switch to a 3D view while in a group, and at some other times as well. However, no matter what syntax and menu names I try (I've checked the constants for this command), I get errors saying the menu cannot be found. Any pointers? Ideally the script would then also zoom to fit objects. Thanks! Cheers, Markus Quote Link to comment
JBenghiat Posted January 23, 2018 Share Posted January 23, 2018 If you want to set projection and render mode directly, look at the Projection command: http://developer.vectorworks.net/index.php/VS:Function_Reference#View_.2F_Zoom For DoMenuText, render and projection are sub menus, so you need to use the second parameter and the correct menu “chunk” http://developer.vectorworks.net/index.php/VS:Function_Reference_Appendix#chunk Quote Link to comment
Markus Barrera-Kolb Posted January 24, 2018 Author Share Posted January 24, 2018 Thanks JBenghiat, I gave this a try with no success (syntax copied below). Also, it seems like this function necessarily sets the view distance and crop dimensions, but I'd like to keep the ones that are already set prior to running the script... PROCEDURE ProjectionPerspectiveOpenGL; BEGIN Projection(1,11,5,-12,-12,12,12); END; RUN (ProjectionPerspectiveOpenGL); And the syntax I was trying with DoMenuTextByName was (I got these from Appendix H): PROCEDURE Perspective_OpenGL; BEGIN DoMenuTextByName('OpenGL Render Chunk',0); DoMenuTextByName('Perspective Chunk',2); END; RUN (Perspective_OpenGL); Quote Link to comment
Kevin McAllister Posted January 24, 2018 Share Posted January 24, 2018 2 hours ago, Markus Barrera-Kolb said: Thanks JBenghiat, I gave this a try with no success (syntax copied below). Also, it seems like this function necessarily sets the view distance and crop dimensions, but I'd like to keep the ones that are already set prior to running the script... PROCEDURE ProjectionPerspectiveOpenGL; BEGIN Projection(1,11,5,-12,-12,12,12); END; RUN (ProjectionPerspectiveOpenGL); And the syntax I was trying with DoMenuTextByName was (I got these from Appendix H): PROCEDURE Perspective_OpenGL; BEGIN DoMenuTextByName('OpenGL Render Chunk',0); DoMenuTextByName('Perspective Chunk',2); END; RUN (Perspective_OpenGL); There used to be a menu plugin that switched to perspective and OpenGL that I shared on the old forum. The links are all broken so I dug around in my archives to find it. It seems like some of the items numbers have changed in more recent versions. After some fiddling I could get this code to work - DoMenuTextByName('Projection',5); {sets projection to normal perspective} DoMenuTextByName('OpenGL Render Chunk',1); {sets rendering to OpenGL} I've also attached the menu plugin as well. I used to put it into the right click contextual menu. It turns cropped perspective off, sets the projection to normal perspective and makes the Flyover Tool active. Maybe someone else knows how to access the zoom settings to make it zoom to objects as well. I don't see any way to set the zoom in Vectorscript other than by percent. Kevin Perspective View.vsm Quote Link to comment
Markus Barrera-Kolb Posted January 24, 2018 Author Share Posted January 24, 2018 Thanks Kevin, your syntax for DoMenuTextByName did the trick! Now I can reliably switch from Top/Plan into my preferred 3D view even while inside a group! Cheers, Markus Quote Link to comment
Markus Barrera-Kolb Posted January 25, 2018 Author Share Posted January 25, 2018 (edited) Kevin, et al, I'm confused – I was working on my laptop at home yesterday when I got the script to work with DoMenuTextByName (see below). Today I installed the identical script on my machine at work, also running VW2018 SP2 with the same workspace, and it refuses to run, giving an error message saying that the menu cannot be found. I have no clue what's amiss... Any ideas? Thanks! Cheers, Markus PROCEDURE PerspectiveOpenGL;BEGINDoMenuTextByName('Projection',5);DoMenuTextByName('OpenGL Render Chunk',1);END;RUN (PerspectiveOpenGL); Edited January 25, 2018 by Markus Barrera-Kolb Quote Link to comment
Pat Stanford Posted January 25, 2018 Share Posted January 25, 2018 Different workspaces? I think that DoMenuText depends on the location of the command in the workspace, so if you modify your workspace to put it somewhere else or to remove that command it may not work. Quote Link to comment
Markus Barrera-Kolb Posted January 25, 2018 Author Share Posted January 25, 2018 ...weird, the workspaces are essentially identical – certainly both have these commands in their original menu positions – but I just loaded my home laptop's workspace on my work machine, and now the script works on both. Go figure! Thanks for your help & feedback everyone! Cheers, Markus Quote Link to comment
JBenghiat Posted January 26, 2018 Share Posted January 26, 2018 Here is a script that uses the view functions, so it isn't workspace / menu dependent. In addition to setting the projection, the script gets and restores the view and zoom and doesn't crop the perspective view. This is in python to avoid the need to declare variables, but steps in VS would be exactly the same import vs varPerspectiveCropped = 127 xAngleR, yAngelR, zAngleR, offsetPt = vs.GetView() zoom = vs.GetZoom() vs.Projection(1, 11, 9.76, -1, -1, 1, 1) vs.SetView(xAngleR, yAngelR, zAngleR, offsetPt[0], offsetPt[1], offsetPt[2]) vs.SetPref(varPerspectiveCropped, False) vs.SetZoom(zoom) 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.