By polykat
#268006
-- for the solution scroll to the end of this thread --

Hi Everyone,

unfortunatelly I don't understand how to use the new Maxwell Animation Functions to export an mxs-series for my Bongo-Animation. Maybe, I'm doing something wrong...

So I tried to solve my problem with a Rhino Script. This ist my first script and I'm no programmer, so it is not nice and doesn't know how to react on wrong input and ESC, but ist works.

My Problem now is: With every Maxwell_RenderToMxs RenderScene Some amount of Ram is filled and I don't know how to free it. Maxwell_ClearCachedData doesn't help and Maxwell_CancelAnimation doesn't either.
If I try to render an animation of more than 80 frames my Ram is filled up and Rhino crashes. :cry:

Is anyone here who can help or has an idea what to try?

Here's my Rhino Script:
Code: Select all
Option Explicit
'Script written by ADF
Public strAnimPath, strAnimName, strImageType, intNr, blnMXI
Sub MWRBA
  Dim i, z, intStartFrame, intEndFrame, intByFrames
  intNr = 0
  'Rhino.Command "! _Maxwell_BeginAnimation"
  intStartFrame = Rhino.GetInteger("First Frame", 0, 0)
  intEndFrame = Rhino.GetInteger("Last Frame", intStartframe+10, intStartframe)
  intByFrames = Rhino.GetInteger("Render every n-th Frame", 1, 0, intEndFrame)
  strAnimName = Rhino.GetString("Sequence Name")
  strAnimPath = Rhino.BrowseForFolder( Rhino.DocumentPath , "Please select the home folder for this render sequence.", "Select animation Folder")
  If Not IsNull(strAnimPath) Then
    Rhino.Print strAnimPath
  End If
  Dim arrFormats(5)
  arrFormats(0) = "tif"
  arrFormats(1) = "tga"
  arrFormats(2) = "jpg"
  arrFormats(3) = "png"
  arrFormats(4) = "bmp"
  arrFormats(5) = "hdr"
  strImageType = Rhino.GetString("Image Format", "png", arrFormats)
  
  'Write MXI YES/NO
  Dim arrItems, arrDefaults, arrResults
  arrItems = Array( "WriteMXI", "NO", "YES", _
                    "FrameNumbering", "BongoTimeline", "StartWith_1" )
  arrDefaults = Array(False, True)
  arrResults = Rhino.GetBoolean("Write MXI or not", arrItems, arrDefaults)
  
  'Create Project Folder
  Dim filesys, newfolder, newfolderpath
  newfolderpath = strAnimPath & strAnimName
  Set filesys=CreateObject("Scripting.FileSystemObject")
  If Not filesys.FolderExists(newfolderpath) Then
    Set newfolder = filesys.CreateFolder(newfolderpath)
  End If
  'Create MXS Folder
  newfolderpath = strAnimPath & strAnimName & "\MXS"
  If Not filesys.FolderExists(newfolderpath) Then
    Set newfolder = filesys.CreateFolder(newfolderpath)
  End If
  'Create Output Folder
  newfolderpath = strAnimPath & strAnimName & "\Output"
  If Not filesys.FolderExists(newfolderpath) Then
    Set newfolder = filesys.CreateFolder(newfolderpath)
  End If
  'Create MXI Folder
  If arrResults(0) = True Then
    newfolderpath = strAnimPath & strAnimName & "\MXI"
    If Not filesys.FolderExists(newfolderpath) Then
      Set newfolder = filesys.CreateFolder(newfolderpath)
    End If
    Rhino.Command "Maxwell_RenderSettings WriteMXI=Yes _Enter"
  Else
    Rhino.Command "Maxwell_RenderSettings WriteMXI=No _Enter"
  End If
  Rhino.Command "BongoSchieberpositionDefinieren " & intStartFrame
  For i = intStartFrame To intEndFrame Step intByFrames
    If arrResults(1) = True Then
      z = z+1
    Else
      z = i
    End If
    intNr = Right("00000" & Left(Int(z), 4), 4)
    blnMXI = arrResults(1)
    RenderFrame
    If i < intEndFrame Then
      Rhino.Command "BongoSchieberpositionDefinieren "& i+intByFrames
    End If
    'Rhino.Command "Maxwell_ClearCachedData"
  Next
  Rhino.Command "Maxwell_ClearCachedData"
  Rhino.Command "BongoSchieberpositionDefinieren " & intStartFrame & " _Enter"
  'Rhino.Command "! _Maxwell_CancelAnimation"
End Sub

Sub RenderFrame
    Rhino.Command "Maxwell_OutputSettings ScenePath " & strAnimPath & strAnimName & "\MXS\" & strAnimName &"_"&  intNr & ".mxs ImagePath " & strAnimPath & strAnimName & "\Output\" & strAnimName &"_"&  intNr & "." & strImageType & " _Enter"
    If blnMXI = True Then
      Rhino.Command "Maxwell_RenderSettings MXIPath " & strAnimPath & strAnimName & "\MXI\" & strAnimName &"_"&  intNr & ".mxi _Enter"
    Else
      Rhino.Command "Maxwell_RenderSettings MXIPath " & strAnimPath & strAnimName & "\" & strAnimName & ".mxi _Enter"
    End If
    Rhino.Command "Maxwell_RenderToMxs RenderScene"
    Rhino.Command "Maxwell_ClearCachedData"
End Sub
Last edited by polykat on Thu May 01, 2008 12:25 pm, edited 1 time in total.
By JDHill
#268010
Hi polykat,

Can you tell me which plugin version you're currently running? I am testing this here with script or with AnimationTools (I don't have Bongo), and I don't see any problem with memory-usage. If you're using version 1.6.8, you don't need to do all of that mxs, image, and mxi naming in your script. If you just go to Plugin Options and set 'Always Write MXI' and 'MXI Auto-Naming' to 'Yes', you can run a script as simple as this:
Code: Select all
Rhino.Command("! _Maxwell_BeginAnimation")
For i = 0 To 36
  Rhino.TiltView "Perspective", 0, 10
  Rhino.Command("_Render")
Next
Rhino.Command("_Maxwell_EndAnimation")
This will result in:

- a folder named [3dmName]_animation being created, next to the current 3dm
- inside that folder, two other folders: Mxs and Output
- in the Mxs folder will be all of the MXS files, already named incrementally, like [3dmName]_0001.mxs, etc.
- when you give the Maxwell_EndAnimation command, MXCL will be started, and it will render all of the MXS files into the Output folder
- setting the MXI plugin options as above will make MXCL write an MXI for each MXS, using a matching filename

Like I said, I don't see any memory increase here, so if you can provide any more details, it would be good.

JD
By polykat
#268013
Hi JD,

thanks for your reply. I will try your script in a moment.
I have Maxwell Plugin 1.6.8.0
Rhino 4 SR3
Bongo 1.0.5.0

The memory increase only happens when geometry is animated. No problem with only camera animation. Hope I cen tell you more in a few minutes...

Andras
By polykat
#268021
Hi JD,

now I tried your script. I only had to modify the function that jumps to the next frame of the animation:
Code: Select all
Rhino.Command("! _Maxwell_BeginAnimation")
For i = 1 To 30
  'Rhino.TiltView "Perspective", 0, 10
  Rhino.Command "_BongoSetSliderPosition "& i
  Rhino.Command("_Render")
Next
Rhino.Command("_Maxwell_EndAnimation")
Unfortunately as soon as geometry is animated, the Ram gets filled and even after the export script finished, Ram stays filled up. Only closing Rhino frees it.

BUT...

I tried this:
Code: Select all
Rhino.Command("! _Maxwell_BeginAnimation")
For i = 1 To 30
  Rhino.Command "_BongoSetSliderPosition "& i
Next
Rhino.Command("_Maxwell_EndAnimation")
And still the same problem. --->>> It's not the Maxwell _Render-Function fault!

Then I tried this:
Code: Select all
For i = 1 To 30
  Rhino.Command "_BongoSetSliderPosition "& i
Next
Still the same. So it's not the Maxwell Plugin at all. That's good for you and sad for me. Because you allways can help if problems are caused by the Plugin. So I will :cry: and try the Bongo-Support.

Thanks, Andras
By polykat
#268031
Just to complete this thread....

The solution is sooooo simple:

_BongoRefresh clears the RAM.
Code: Select all
Rhino.Command("! _Maxwell_BeginAnimation")
For i = 1 To 100
  Rhino.Command "_BongoSetSliderPosition "& i
  Rhino.Command("_Render")
  Rhino.Command("_BongoRefresh")
Next
Rhino.Command("_Maxwell_EndAnimation")
By JDHill
#268038
Thanks for that, Andras. People have asked about Bongo, and I'm glad you've been able to make them work together. I've tried to do that myself, but as I said, I don't own Bongo. In the past, I've even made a little spy plugin that I sent to a friend who has Bongo - it would listen and try to print any Bongo-related commands which were given during an animation. But I wasn't able to make enough sense of the results to get anything working with the Maxwell plugin...so it's good to find you can get the job done with seven lines of RhinoScript. :)

Thanks,

JD
By polykat
#268063
Hi JD,

Thanks! But there's a problem. The code is not working. :cry:

If I type in _BongoRefresh to the Rhino command line, RAM is emptied. But if a script should do that, nothing happens. I don't understand it. Even this simple script is not working:
Code: Select all
Sub MemClear
  Rhino.Command("_BongoRefresh")
End Sub
In the command line everything looks like the command was executed. Even the Rhino.LastCommandResult says Success, but RAM is still full. Typing in _BongoRefresh manually instantly frees all the missing RAM.

I seem to have tomatos on my eyes, as we in Germany say. I contacted the Bongo Forum, maybe they can help.

Andras
By polykat
#268064
By the way, if you're interested, here are the Bongo Commands:
Image[/img]
User avatar
By polynurb
#268221
Hi polykat,

nice coding effort!

.. hopefully mcNeel can tell you what's going on there...
( is bongoRefresh listed under scriptable commands?)

maybe worth a try: using _clearUndo instead of _bongoRefresh
; clearUndo is about the only command i know in rhino that can sometimes free a lot of ram.

(i will try your script as soon as i get time to experiment a bit....)

Grüße aus wien,

polynurb
By polykat
#268287
Polynurb YOU ARE A GENIUS!

That solves the problem. The script works now:
Code: Select all
Rhino.Command("! _Maxwell_BeginAnimation")
For i = 1 To 100
  Rhino.Command "_BongoSetSliderPosition "& i
  Rhino.Command("_Render")
  Rhino.Command("_ClearUndo")
Next
Rhino.Command("_Maxwell_EndAnimation")
I'm using it with a counter, because _ClearUndo takes some time:
Code: Select all
Rhino.Command("! _Maxwell_BeginAnimation")
counter = 0
For i = 1 To 100
  Rhino.Command "_BongoSetSliderPosition "& i
  Rhino.Command("_Render")
  If counter = 10 Then
    Rhino.Command("_ClearUndo")
    counter=0
  End If
  counter = counter+1
Next
Rhino.Command("_Maxwell_EndAnimation")
Thanks again for your help JD and Polynurb,

Andras
By JDHill
#268296
Excellent. :)
By Polyxo
#268327
Hi Jeremy,
good to see Mw working with Bongo. Could you maybe add the essential information to the sticky "Did you know" thread?

Thanks, Holger
By JDHill
#268328
Sure thing, Holger. :)
User avatar
By polynurb
#268333
..cool.

glad that helped.. :D

thnx to you making that thing work!

cheers,

polynurb
render engines and Maxwell

well I don't think AI will remain like it is now. […]

Help with swimming pool water

Hi Andreas " I would say the above "fake[…]