Jump to content

Can a script change viewport class/layer visibilities?


Recommended Posts

1 hour ago, Jesse Cogswell said:

@SamIWas ,

@line-weight mentioned in the original post that they have been using the eyedropper tool to do this, but it becomes very tedious if you have a large number of viewports spread across multiple sheet layers, the tool I wrote and posted above allows you to do it all in one go, and has the ability to force the viewports to run an update as well.

 

Sigh...that's what happens when I don't finish reading the entire post and move on to the responses....🤔

 

Link to comment

Yes, this script is great and is saving me a lot of time and tedium on one particular project where I have a large number of viewports with quite complicated class setups.

 

The eyedropper tool can be slow, not just because you have to go around each viewport manually, but because of the slowness with which Vectorworks opens up and draws sheet layers with large numbers of viewports (something that might have improved somewhat in later versions, but at least in VW2018 which I'm still using, switching between such sheet layers is incredibly lethargic and tedious).

 

Being able to tick the box that re-renders all the viewports you've just updated also saves quite a lot of time (although, if I had one further suggestion to @Jesse Cogswell it would be that this box should be un-ticked rather than ticked by default, as it's quite easy to unintentionally set VW off on a redraw when you didn't meant to).

Link to comment

@line-weight , ask and you shall receive.  The script will now save the choice from the Attributes to Copy drop-down as well as the Update Viewports checkbox to a resource file and will recall those settings the next time you run the command.  This is set globally, so these settings will be recalled regardless of which drawing you have open.  Update Viewports will be unchecked by default the first time you run the tool.

Copy Viewport Settings.vsm

  • Like 2
Link to comment
  • 1 year later...
14 hours ago, Jesse Cogswell said:

Updated plug-in attached.  Let me know if this creates any bugs or issues that I might have missed in my (admittedly rather quick) testing.

Copy Viewport Settings.vsm 15.7 kB · 4 downloads

 

Thanks very much! Seems to work fine. Really appreciate you doing this.

 

Not expecting anyone to write this for me, but here is another thing that would be really useful to automate:

>Activate saved view A

>Create viewport named "A" on sheet layer X

>Activate saved view B

>Create viewport named "B" on sheet layer X

>Activate saved view C

>Create viewport named "C" on sheet layer X

etc etc

 

Would that be complicated to do, in principle?

Link to comment

Not hard in principle but probably a tricky implementation.  Saved Views are basically already just a script that changes visibility and views. So you can change to View A, but there is no way to test and see what view you are in. If you make the user choose from a dialog of Saved Views you should be able to grab the names you need to create the viewports.

 

Any reason you want to do it serially? Could you not have the user choose all the Saved Views they want and then generate all the viewports at once?

 

Link to comment

@line-weight I've run some tests this morning and think I have a handle of this and am working on a script for you.  It will launch a dialog showing all Saved Views, allowing you to select them, choose a Sheet Layer, and set things like Viewport Name, Drawing Number, and Drawing Title before cycling through the selected views and creating Viewports.

 

As @Pat Stanford mentioned, Saved Views are a little tricky, so at the moment it will be creating viewports strictly based on the class and layer visibilities of the Saved Views, not the screen view itself.  It IS theoretically possible to pull the screen view and use that to create a crop, but it is a fair bit trickier.

  • Like 1
Link to comment

Yes please don't put loads of time into this unless there is some enjoyment in it for you @Jesse Cogswell! It is something that would be really handy for me in managing a particular project, and would save me some tedium but it's also a process that I can do manually without it being a big deal.

 

@Pat Stanford no need for it to happen serially - choosing from a list and generating at once would be fine.

 

To explain the purpose of this, it's really just a way of applying (very large) bunches of class visibilities that are saved as saved views, and applying these to already existing viewports. As I work on the model, a gradually add elements that get assigned to different classes and each of these classes is then made visible in one or more of my saved views. So the saved view setups can gradually evolve as I work on things, and I use them all the time to flip between different states of the model, but I also have viewports set up to produce renderworks images which are the final output of the process. Each of these viewports has a class visibility setup that matches one of those saved views, but there is no way of having them update themselves in parallel automatically. So, periodically, I have to update each of those viewports.

 

At the moment the process to do this is to view the model in an arbitrary view, activate each of the relevant saved views, and for each of them create a viewport on a "master viewports" layer. It doesn't matter what these viewports look like, all that matters is that each of them contains the right combination of class visibilities to match each of my standard saved views.

 

Then when I have all those master viewports generated, I use the script that @Jesse Cogswell kindly already provided, to copy the class visibilities from each of those master viewports, to a bunch of the final output viewports. Sometimes I am wanting to copy each master viewport to three 'final' viewports, and in other scenarios I want to copy them to ten or twenty. The script I already have makes this process hugely less tedious than it was previously (I had to go round with the eyedropper tool, and VW responds very sluggishly when you use it to copy class visibilities).

 

So this other script would be about the generation of the master viewports each time I want to update them. It would streamline the current process of

-go to design layer

-activate saved view

-wait for model to update

-choose "create viewport"

-deal with the settings dialogue (including typing in a name for the viewport)

-wait for VW to produce the saved view on the sheet layer

-navigate back to the design layer view

-activate the next saved view ... and so on, eight or ten times over, each time I want to do this.

  • Like 2
Link to comment

@line-weight All right, give this a shot.  When you select a saved view, press the button at the bottom to set things like where the viewport should live, what its name should be, etc.  If you select the saved view without setting the options, it will default to the top sheet layer.  It will also do an error check on the viewport name, but if you leave it blank it will do the standard "Viewport-X" scheme that VW does automatically.  Also, pressing the button with the saved view selected will automatically put a check in the Selected column.

 

This only looks at class and layer visibilities, and will rope in stuff set to "Ignore" if you're not careful (it loads the Saved View, pulls the current layer and class visibilities, then builds the viewport and applies them, if the class or layer is set to ignore in the saved view but is visible at the time you run this command, it will end up in the viewport).

 

It also pulls the scale of the active layer to apply to the viewport, so it works best if you have the saved view Active Layer set to something other than "Don't Save", since then if you run the command while a sheet layer is active, your viewport will be at 1:1 scale, which probably isn't ideal.

 

The plug-in was written in VW2019 but tested in both VW2021 and VW2022, so let me know if something doesn't work right for you.

Saved Views to Viewports.vsm

Link to comment

Hi Jesse,

 

Your 'Copy Viewport Settings' script is very useful. Could you perhaps add the sheet name to the list? Perhaps showing it when hovering the sheet number, to save some screen space? This would help orientating a lot.

 

Thanks☺️

Sheet name.JPG

Edited by MarcelP102
Link to comment
8 hours ago, Jesse Cogswell said:

@line-weight All right, give this a shot.  When you select a saved view, press the button at the bottom to set things like where the viewport should live, what its name should be, etc.  If you select the saved view without setting the options, it will default to the top sheet layer.  It will also do an error check on the viewport name, but if you leave it blank it will do the standard "Viewport-X" scheme that VW does automatically.  Also, pressing the button with the saved view selected will automatically put a check in the Selected column.

 

This only looks at class and layer visibilities, and will rope in stuff set to "Ignore" if you're not careful (it loads the Saved View, pulls the current layer and class visibilities, then builds the viewport and applies them, if the class or layer is set to ignore in the saved view but is visible at the time you run this command, it will end up in the viewport).

 

It also pulls the scale of the active layer to apply to the viewport, so it works best if you have the saved view Active Layer set to something other than "Don't Save", since then if you run the command while a sheet layer is active, your viewport will be at 1:1 scale, which probably isn't ideal.

 

The plug-in was written in VW2019 but tested in both VW2021 and VW2022, so let me know if something doesn't work right for you.

Saved Views to Viewports.vsm 13.54 kB · 2 downloads

 

Thanks!

 

I'm not managing to get it to work on the drawing that I want to use it on. It just doesn't seem to produce any viewports. Tell it to produce the vports on a certain sheet layer, but the layer is just empty. I've tried turning on all classes, etc, and doing "select all" in case the viewports are tiny or away from the origin. I can also use your other script to see if the viewports exist anywhere but this confirms they don't, because they don't appear in that dialogue box.

 

However, I've tested it on a new very simple file, and it works there.

 

I've also tested it on one of my other "real" projects, and it seems to work there too.

 

So I am trying to think if there is anything special/unusual about the file where it isn't working. The only real difference I can think of is that it's quite a lot larger and more complex. I'll try and do a bit more detective work later today to see if I can work out what's happening. let me know if you have any suggestions for things to check.

Link to comment

@line-weight I only tested the script on a handful of files, none of them terribly large.  I'll try to get some time tonight to test it on a much larger file and nail down the issue.  In the meantime, could you PM me a list of the Layer names and Saved View names?  There might be a naming conflict somewhere preventing the viewports from being created.

 

Also, which VW version are you currently using?

Link to comment
13 minutes ago, Jesse Cogswell said:

@line-weight I only tested the script on a handful of files, none of them terribly large.  I'll try to get some time tonight to test it on a much larger file and nail down the issue.  In the meantime, could you PM me a list of the Layer names and Saved View names?  There might be a naming conflict somewhere preventing the viewports from being created.

 

Also, which VW version are you currently using?

 

I'm using VW2021 at the moment. I'll PM you that list in a second. Thanks.

Link to comment

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.

×
×
  • Create New...