Jump to content
markdd

Worksheet of Viewports and scale

Recommended Posts

I would like to create a worksheet of all the Viewports in my drawing and most specifically what scale they are. Available criteria for viewports are limited. Is there a worksheet function I could use to achieve this?

 

Many thanks.

 

Mark

Share this post


Link to post

This can only be done using a Worksheet Script. I can provide the script. Are you up for a bit of a learning curve on how to use it?

 

 

Share this post


Link to post
Posted (edited)

Yes please! Always looking to find new ways to customise Vectorworks.

Edited by markdd

Share this post


Link to post

OK, here you go.

 

There are two scripts attached. One that returns the scale as a real number, the other that returns it as a string showing as "1:Scale".

 

If you save these scripts into your file (any script palette will do), then you can call them in a worksheet by using a function of "=RunScript('ScriptName')". Where the script name is replaced by the name you are showing in the script palette. Copy everything in the code blocks below. You can name the scripts anything you want, but I named them "Get_VP_Scale" and "Get_VP_Scale_Text".

 

If you want to be able to use these across multiple files without having to have the script in each file, create a new VW file that contains the script(s) and save it in the Defaults folder for Reports and Schedules.  /Users/Your User Name/Library/Application Support/VectorWorks/2017/Libraries/Defaults/Reports_Schedules.  

 

Then modify the function in the worksheet to "=RunScript(120,'ScriptName')

 

If you need a different format, the scripts can be embellished as necessary to do other processing of the numbers/text to get the output you want.

 

Procedure Get_VP_Scale;

Var	H1:Handle;
	R1:Real;
	
	
Begin
	H1:=WSScript_GetObject;
	R1:=GetObjectVariableReal(H1,1003);
	WSScript_SetResReal(R1);  

End;

Run(Get_VP_Scale);

 

Procedure Get_VP_Scale_Text;

Var	H1,H2:Handle;
	N1:Integer;
	R1:Real;
	S1:String;
	
	
Begin
	H1:=WSScript_GetObject;
	R1:=GetObjectVariableReal(H1,1003);
	WSScript_SetResStr(Concat('1:',R1));  

End;

Run(Get_VP_Scale_Text);

 

Share this post


Link to post

Many thanks Pat. I'm very grateful.

 

I'll report back with how I get on. 

 

Mark

Share this post


Link to post

These work like a charm. Thank-you.

 

If I wanted to get other information from the viewport like Drawing title, number, name etc., what part of the script would I adapt? Also, where would I find information within the help files to find the necessary information so I can do it for myself and hopefully learn a little more about scripts etc....

 

Thanks.

 

Mark

Share this post


Link to post

Start with the Vectorscript Appendix. There is a section showing all of the ObjectVariables for viewports. That will give you a starting point. This should be in your VW folder under VWHelp:Script Reference.

 

And keep asking until you get what you need.

  • Like 1

Share this post


Link to post

Thanks Pat

 

I have found the info and I think I understand it. What I can't seem to find in the appendix under viewports, is any reference to the Drawing Title field and the Drawing Number field. Could you guide me as to how I could pull that kind of info into a worksheet.

 

Many thanks 

 

Mark

Share this post


Link to post

Drawing title and Drawing number are combined into the viewport object Name field at the bottom of the shape pane of the OIP.

 

It can be accessed in a database with a formula of =N

 

I will see if I can find a way to access the fields individually.

Share this post


Link to post

Many thanks Pat.

 

 I've managed that, but wondered how I could get the Drawing Title field and the Drawing Number fields individually.

 

Mark

Share this post


Link to post

GetObjectVariableString(FSActLayer,1032) = Drawing Title (listed as Viewport Description in the Appendix)

GetObjectVariableString(FSActLayer,1033) = Drawing Number (listed as Viewport Locator in the Appendix).

Share this post


Link to post

Thanks Pat.

 

I've tried the above and I just get errors. Could you put above into the context of the earlier script that you wrote for me? At least that way I can see what I am doing wrong.

 

Many thanks

 

Mark

Share this post


Link to post
Procedure Get_Drawing_Title;

Var	H1,H2:Handle;
	N1:Integer;
	R1:Real;
	S1:String;
	
	
Begin
	H1:=WSScript_GetObject;
	S1:=GetObjectVariableString(H1,1032);
	WSScript_SetResStr(S1);  

End;

Run(Get_VP_Scale_Drawing_Title);

Create the above script with a name of Get_Drawing_Title and then use a function in the worksheet of "=RunScript('Get_Drawing_Title')" just like you used the other worksheet scripts.

 

The type of data returned (in the _SetRes line) must match the type of data provided, so if you are getting a sting it will be WSScript_SetResStr, for real _SetResReal, etc.

Share this post


Link to post

Thanks Pat. I'll look into this later today.

 

Mark

Share this post


Link to post

I've taken your advise and learned loads. The resulting worksheet is just what I need. Many thanks.5a65e1fb996f4_ScreenShot2018-01-22at13_06_43.thumb.png.1b84f1c924cb0101ecd8b82b981e3311.png

 

Mark

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

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