I must set the activeview to the top view, and after get a capture to export the model from this view at jpg.
My doubt is, How Do I guarantee to set the view at top?
I’m working in c# with rhinocommon and with Spanish language, so i can´t use the field name to search the top view by name if I want translate the Plugin to others languages.
You could also check that the view is a parallel view and then compare the view direction to Array(0,0,-1).
That way you are future-proof for any language.
I have not done that before, nor used python yet, so it would take me some time to fiddle out the correct code, but I am sure @dale or any other wizard could hack it down pretty quickly.
Yes, as a matter of fact, I would not even bother with view names, I would just set up the camera/target/projection, etc. the way you want it in the script. Views and viewports are notoriously hard to deal with in Rhino, given that viewport names can be different when localized and that the name of a viewport may not have anything to do with the actual view that’s in there…
I needed some code for this, and stumbled across this old discussion, so in case somebody (probably me again ) stumbles across this in the future, here is a simple code I made for this:
# --- CHECK IF VIEW IS A TOP VIEW
view = rs.CurrentView()
# --- ViewProjection == 1 is a parallel view
if not rs.ViewProjection(view) == 1:
print("This is a perspective view and not a top view")
return
target = rs.ViewCameraTarget(view)
vector = target[1]-target[0]
# --- The vector needs to be (0,0,-something)
if vector.X == 0 and vector.Y == 0 and vector.Z < 0:
print("View IS a top view")
else:
print("This is NOT a top view")
return