Working with multiple RhinoDocs

Hi,

I want to traverse a number of RhinoObjects and for each object:

  1. Move it to origo.
  2. Rotate it.
  3. Export it to STEP.
  4. [Move it back to it’s initial position.]

It feels like the wrong way to do it: what if an error happens? From the user’s perspective the geometry randomly moved to origo and was rotated. Now they need to move it back.

Therefore I’m thinking of doing this instead:

  1. Create new document.
  2. For each RhinoObject:
    2.1 Add it to the new doc.
    2.2 Move it to origo in the new doc.
    2.3 Rotate it.
    2.4 Export it.
  3. Delete the new document.

Is this a feasible way to go about it? Are Documents designed for this use case, or am I abusing a concept? Will I get into trouble with doing it this way? Are there any recommended ways to go about it?

Hi @aske,

It might be easier to:

1.) Duplicated the Rhino object
2.) Transform it
3.) Export it
4.) Delete the duplicate

Thoughts?

– Dale

I guess I can wrap everything in a try-finally to make sure I clean up properly.

I take it that Documents are not meant for what I imagined then? :slight_smile:

I think docs are supposed to be what you think they are somewhat in the future, but if you want single .3dm files you could also use File3dm and just add the transformed object to that file. After that you could just open and export every rhino file in a folder.

Hey @roger thanks for the reply!

After that you could just open and export every rhino file in a folder.

You mean from within the runnning application? So I would have multiple Docs open in one session?

You can open files with the File3dm class and read from them, however it is not as straightforward to use as the activedoc you might be thinking of. I’m not exactly sure of all the pitfalls but you can certainly read and write from File3dm objects while having a different active document.

Edit: maybe I misread the question: you can basicly load a list of strings, with each string being a path to a rhino file, and open these by iterating over them using the open command.

1 Like

I guess I can wrap everything in a try-finally to make sure I clean up properly.

Sometimes, when Rhino crashes this type of cleanup doesn’t work and the scene is littered with temporary geometry when opening it up again. This is not a good approach I feel.

@dale should I understand your suggestion as actively discouraging developers from creating a new doc and doing it the way I outlined it? I’m a bit confused because someone else now recommends that I do exactly that over here: FileStp_Write feature wish - #4 by gankeyu

I replied in the other thread. The answer is no we are not discouraging the use of a separate headless doc in V7 if that solves what you are trying to do.

1 Like