Help Scripting a repetitive process of Exports and View Captures

Hi everyone!

So, I work with architectural models & Mass Timber components (glu-lams, CLT, MPP, etc). When we get the model dialed in, I export each piece individually so we can create the shop drawings for them. As part of this process, we also “highlight” the selected piece and capture the view, then insert that into the shop drawing for context.

Anyways, I want to script the repetitive portion of that process. Here’s the step-by-step…

0 - For each unique “name” repeat 1-6
1 - Select all instances of parts with the same name
2 - Export selected
-Save to [Proj_dir]/Exports/[PartName]_SD.3DM
-Save without plugin data / textures
3 - Set Display Color (of selected objects) to Red (or other “highlight” color)
4 - Invert Selection
5 - Set Display Color (of selected objects) to Black (or other “neutral” color)
6 - Capture display to file
-Current View
-Transparent Background
-Resolution (viewport)
-Save to [Proj_dir]/Exports/[PartName]_Highlight.png

I’m pretty sure I can create a simple “button” macro for 3-5. Not sure how to include the parameters for 2 or 6. I have absolutely no clue where to start on programmatically looping through all parts in the model (or in certain layers) by name… My programming experience is mostly in Visual Basic / TI Basic. I have familiarity with Java / C++, at least enough to read / check / tweak. I’ve never coded anything for Rhino though.

With all the options, would this be a task best suited for RhinoScript, Python, or Grasshopper? Whichever one, can you help point me in the right direction to start my research / learning on how? I mean, if you can provide code for what I’m looking for that’s awesome too, but I’m mostly interested in learning how to do these things.

Thanks!

Easiest for you might be to go for RhinoCommon in my opinion, since you have no experience with python but java/c++. However, its not that hard to do these steps with RhinoScriptSyntax inbuilt methods, so if you can live with the idea to learn a bit of python, I would go that route. Should take you one or two days at max I think.

You can do it in Rhinoscript too. It’s a lot easier to start with since you already know Visual Basic.

Spend couple of odd hours reading through this: https://developer.rhino3d.com/guides/rhinoscript/primer-101/

That’s how I started writing scripts for Rhino and the only programming language I knew before that was BASIC.

HI @corey.hokanson,

Give this script a try, its in python, i did some testing and its working so far, feel free to ask all the questions about it :slight_smile:

ExportByNameAndViewCapture.py (3.0 KB)

I Assume you don’t know yet how to run python scripts,

  • Copy they file in C:\Users\User\AppData\Roaming\McNeel\Rhinoceros\6.0\scripts
  • Run the command: -_RunPythonScript ExportByNameAndViewCapture.py
  • Check the results :wink:

Dude! You ROCK!

I’m still going to research and learn how to code for myself, @Asterisk. Thanks a ton for that reference link.

but seriously Lando… that script is amazing. Going to save me so much time…