A macro for displaying a section view?

Hello,
I wonder if it is possible to have a macro to select and display a section view. I mean, I have several sections, some named views, some display modes of my own, and my goal is to have a macro (or a script, at the worst) to set some perspective views, get some sections, and write the results to files.
For now I have something like this:

'-_NamedCPlane _Restore "MY-CPLANE" _Enter
'-_NamedView _Restore "MY-VIEW" _Enter
'-_SetDisplayMode Viewport=Active Mode=MY-MODE
'-_vaSectionView "MY-SECTION" _Enter <--- this one doesn't work...
'-_ViewCaptureToFile Scale 4 LockAspectRatio=Yes _Enter

And it almost works, apart from that I cannot get a section view… Is there any way to get this?

Cheers, Jaro

p.s. I didn’t know I can move the topic by myself :wink:

Hi Jaro,
That’s not possible. The vaSectionView command cannot be scripted right now.

Well, finally I’ve ended up with a script. Works fine :wink:
ezgif.com-resize
Cheers, Jaro

1 Like

Would You mind sharing? :upside_down_face:

Well, why not? The script is quite simple and primitive, I haven’t had time for working on it, I just need the animation. The idea is just to move a VA section within a defined view, displayed with a defined display mode. And there are some “manual” variables, like a section depth (I would like to get it from a section definition), step (this is a single movement of each section, the smaller step the smoother the animation). So, for now it looks like this:

import rhinoscriptsyntax as rs

alias = "VC1"
section_name = "ANIMACJA-PRZEKROJ-B"
section_depth = 64000
step_depth = 320
steps = int(section_depth/step_depth)
start_point = (0,0,0)
end_point = (0,-step_depth,0)
section_movement = rs.VectorAdd(start_point, end_point)

def animacja():
    section = rs.ObjectsByName(section_name, True)
    for step in range(steps):
       rs.MoveObject(section, section_movement)
       rs.Command(alias + ' _Enter')

if __name__ == "__main__":
    animacja() 

The “alias” variable is just an alias :slight_smile: as I thought it was the simplest way to get what I wanted. I have several VCs aliases, differing only in scale of captured view. So, VC1 looks like this:

'-_ViewCaptureToFile Scale 1 LockAspectRatio=Yes _Enter

In effect you will get some pictures, and the rest is to get a GIF. The one above has been made thanks to the Animated GIF Maker. That’s all.

There is quite a lot to improve, maybe someone could smoothen it? :wink: First of all, I would add some interaction to choose alias.

Cheers, Jaro

p.s. I have translated polish names of variables, but I haven’t checked if the english version works…

1 Like