Jump to content
Markus Barrera-Kolb

Help with a script to set Render mode & Projection?!

Recommended Posts

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

Share this post


Link to post

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

Share this post


Link to post

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);

Share this post


Link to post
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

Share this post


Link to post

5a6a1b5985813_ScreenShot2018-01-25at09_41_19.thumb.png.d2898adf3ea2f681ac2b883e3c50048f.pngKevin, 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;
BEGIN
DoMenuTextByName('Projection',5);
DoMenuTextByName('OpenGL Render Chunk',1);
END;
RUN (PerspectiveOpenGL);

 

5a6a1b88ac576_ScreenShot2018-01-25at09_41_19.thumb.png.e3ea8dff2bed73c76684affac025a357.png

Edited by Markus Barrera-Kolb

Share this post


Link to post

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.

Share this post


Link to post

...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

Share this post


Link to post

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)

 

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.

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.


 

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...