Grasshopper

algorithmic modeling for Rhino

Hello

is there any way to get named views resolution size? I took a look at this in rhinocommon examples that prints active viewport resolution.

the aim is to have have lets say 4 views layout in rhino named 1,2,3,4, where the script outputs their resolution, without having to click on each. Switching to fullscreen view 1 in one viewport, or other layout combinations and the script updates to view 1 fullscreen resolution or the other layouts.

thank you in advance for your time

best

alex

Views: 1422

Replies to This Discussion

Hi Alex,

I'm not sure if this is exactly what you're looking for, but it's the best workaround I could come up with quickly. This script sets a NamedView active from a given index, then extracts its properties (similar to the sample you posted above).

I'll keep digging, but I haven't found a nice way to output the RhinoDoc's NamedViews and respective sizes as a list yet.

Cheers,
/SPM

Attachments:

Hello Stephen,

thank you for looking into this. I am a total noob in scripting so i hope the following makes sense.

For some reason the first script listing the stored name views gives me the following red flag.

1. Solution exception:name 'scriptcontext' is not defined

Reading the script, i think, maybe what i am after is not possible, using named views.

It outputs the named views resolutions, but whatever named view i select get maximized and also gets set to whatever selected active view i have in Rhino. This makes the order of the named views, in a 4 view layout, to rearrange which messes the setup i have.

Fiddling a bit with the script setting viewMaximized to False, does not maximize the selected viewport, but stops the auto update of the viewport size too. I guess this happens because since its not maximized it does not register to ActiveNamed view.

So if getting the named views resolutions, without having to click in each,without getting maximized and set to the current selected view is not possible i thought of the following.

What i tried was the example given in rhinocommon

from scriptcontext import doc
 
activeViewport = doc.Views.ActiveView.ActiveViewport
print "{1},{2}".format(
    activeViewport.Size.Width, activeViewport.Size.Height)

and i used it with a timer, so that everytime i click in view,named or not, it gets the resolution. But for some reason my pc hates timer and makes my system luggy. I could work with the above script if somehow the timer, or any other method, was embedded in it, so that when i click in a view it updates the resolution. I have a feeling this is something easy to.

*edit timer also forces a redraw of objects in viewport (hence the lag?)

thank you again

best

alex

and this is what i am after

mesh, text etc to screen components, from Human plugin get their scale auto updated when changing view resolution.

If this is all you need, see the attached definition. It works with the active view instead of named views (like the GIF above). It works on my end, though it is a little laggy.

As far as the scriptcontext module is concerned, just make sure you have the latest GHPython. I haven't run into that specific error before. Check the lib directory (C:\Users\YOURUSERNAME\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib) and make sure that scriptcontext.py is there.

/SPM

Attachments:

ok Stephen, please try not to laugh with my frankencode.

i added the NamedViews and IsViewCurrent

the views/ports, named or not get detected. Also which one is current gets detected too.

what would make this complete is

1.to get the pixels of all of them at once

2.to avoid the comp.ExpireSolution and use maybe a boolean instead, so that the component runs just for some time until the 3 or 4 resolutions get detected-recorded. (when changed and not running all the time). In that case the IsViewCurrent would pass the captured resolution to the appropriate scale input.

hopes this makes sense.

best

alex

Attachments:

Ah! This should do the trick. I cleaned up the script a little bit.

/SPM

Attachments:

Thats it!.

thank you again for your time and solution.

best

alex

Incidentally the as-of-yet unreleased next version of Human contains components to retrieve viewport resolution natively. Check out a preview release below...

Attachments:

solution on steroids.

thanks andrew!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service