Script to save MoI screen shot w/ transparent BG to clipboard
All  1-7  8-10

Previous
Next
 From:  pior (PIOR_O)
10393.8 In reply to 10393.7 
Hello Michael ! Thank you for chiming in so quickly as always.
I absolutely should have been more clear and should have annotated the diagram to begin with. Here goes :



On this diagram I would describe the blue rectangle/boundary as my desired "page". Within this page lies a subject (here a simple character pinup outline, drawn in black), which does not fully fill up the page. That is to say, the bounding box of the content is much narrower than my desired render.

At a high level the thing I am after is a way to render out this rectangular blue "page", at given pixel width and height or as some multiple of its current screen presence (which I could then scale down later, respecting the proportions). 2D vector drawing programs tend to have a few options for that (rendering out the page itself, cropping things down to the bounding box of the art content, and so on).

Of course, having such a rectangle to define the page boundary is just one way I can think of to define this desired rendering area. If I could somehow feed up the coordinates of the 4 corner points (0 0, 0 10, 20 0, 20,10) and instruct the renderer to render the content within these corners at a set pixel width/height, that would work too.

The one tricky aspect of it all is that if the page boundaries were to be defined by a rectangle shape in the scene, this shape will have line thickness once rendered, hence the resulting image wouldn't quite match the original layout anymore if the boundaries were defined by the rendered objects with thick lines.

I hope this makes more sense !

EDITED: 12 Aug 2021 by PIOR_O


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10393.9 In reply to 10393.8 
Hi pior,

re:
> If I could somehow feed up the coordinates of the 4 corner points (0 0, 0 10, 20 0, 20,10) and instruct
> the renderer to render the content within these corners at a set pixel width/height, that would
> work too.

Well the renderer just renders the view, there isn't any way to tell it to render something different. So you would need to manipulate the view to do what you need.

For a first step if you trigger a Reset on the view, that will center it on the bounding rectangle of the selected objects but leave a little bit of border space around it. Then for an ortho view the size of the viewplane can be set to the size of the geometry to frame it without any border space.

That would go something like this:

script: var objs = moi.geometryDatabase.getSelectedObjects(); var vp = moi.ui.getActiveViewport(); if ( vp.projection == 'Parallel' && objs.length > 0 ) { vp.reset( 'selected' ); var bbox = objs.getHighAccuracyBoundingBox(); vp.fieldOfViewAngle = bbox.yLength; }

I think the on screen display may not show the top and bottom of the objects because they will be running right over the border decorations of the viewport but on a scripted render call the border decorations won't be shown.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  pior (PIOR_O)
10393.10 In reply to 10393.9 
Well, this is *exactly* it ! All I had to do was to feed it square values (in this present case, 4096*4096), otherwise I somehow end up with a smaller rendered "page" inside the full render - and then all I have to do is to crop the result down to 4096*2048 in PS. This basically saves me about 10 minutes of exporting/importing back and forth to other vector applications just to get my precise lineart render out of MOI. And with the ability to render to clipboard I don't even have to worry with intermediate files anymore either. And of course everything lines up perfectly with the original layout, this is brilliant. Thank you so much !

FWIW the full code turns out to be :

script: var objs = moi.geometryDatabase.getSelectedObjects(); var vp = moi.ui.getActiveViewport(); if ( vp.projection == 'Parallel' && objs.length > 0 ) { vp.reset( 'selected' ); var bbox = objs.getHighAccuracyBoundingBox(); vp.fieldOfViewAngle = bbox.yLength; }; var prev_background = moi.view.viewportBackgroundColor; moi.view.viewportBackgroundColor = 0xFFFFFF; moi.view.lineWidth = 2; moi.grid.display = false; moi.grid.showXYAxes = false; moi.view.showAxisIcon = false; moi.view.showViewTitles = false; var img = null; try { img = moi.ui.getActiveViewport().renderToClipboard( 4096, 4096 ); } catch(e){} moi.view.lineWidth = 1; moi.grid.display = true; moi.grid.showXYAxes = true; moi.view.showAxisIcon = true; moi.view.showViewTitles = true; moi.view.viewportBackgroundColor = prev_background;

EDITED: 12 Aug 2021 by PIOR_O

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1-7  8-10