How to set scale and target of detail?




This is probably a python/rhinoCommon beginners question, but I cant seem to solve it on my own.

I want to create a layout, add a detail view to the layout (top view, but preferably changeable to any other ‘standard view’). So far I have managed this by:

if RUN == True:
    rs.AddLayout(name, size)

for layout in sc.doc.Views.GetPageViews(): 
sc.doc.Views.ActiveView = layout
layout.AddDetailView(name + '1', corner1, corner2, r.Display.DefinedViewportProjection.Top)

I then want the detail view to center over a target point in the rhino document and zoom so it shows the objects in the detail in a certain scale. Should I first create a DefinedViewportProjection that is centered over the target, and then use this to add the detail, or should I rather move the camera after creating the detail? I can’t find a method to set the camera of a detail view or zoom. Please help!

(Giulio Piacentino) #2

I am completely not knowledgeable of anything Detail/Layout. However, I see rs.DetailScale() and rs.ViewCameraTarget() as possible methods for this.

Do they help?


Hey Gulio, thanks for your reply.
In the end I installed visual studio and did this in c# using SetCameraLocation and SetScale. Although python may be easier to grasp at first i found the sdk-help for c# really great, making it easy to know what to input where and to search for methods. It would be fantastic If there is something similar for writing Python!!

(Steve Baer) #4

Can you provide a link to what specific SDK help made the difference for C#? We are putting a lot of effort into improving our SDK documentation all around and I would like to see where we can make improvements.


Hey Steve,
Apologies for my late reply, I haven’t had the time for this until now.

I think my previous reply to Guilio was a bit incorrect. However, I think it comes down to mainly three aspects which to me provided better support for writing this in C# than in Python, even though I’m much more familiar with the Python syntax, and more or less a complete stranger to C#. Writing in C# I’ve been using “Visual Studio Community” and when I’ve been scripting in Python, I’ve used the ghPython component. Maybe there are softwares like visual studio that provide more support, in which I could write and debug my grasshopper python scripts?

Anyway, these are that I found made it easy to make this in C# instead.

  1. The great autocomplete function in visual studio very rigorously describe for instance what arguments and types a method takes using both text and color. The ghPython component seem for some reason to give a much longer list of classes/methods etc to access from each, which in this particular case made it harder to find what I was looking for. See pic:

The grasshopper Add-on template is very clear about the different steps and what is required to setup before you can run the component. I also think it makes sense to define the inputs/outputs from within the component, making it slightly more convenient to go back and look at it while writing.

The lack of python examples in the online rhinocommon SDK. Are there any?