Everything related to the integration for Rhinoceros.
User avatar
By Q2
#395877
OK, here's another one...

How do I change the intensity value of an emitter in an Bongo animation, so that any chosen emitter in my scene turns on slowly?

Any ideas?

Thanks and cheers again....

Q!
By JDHill
#395879
The plugin does translate native Rhino lights (creating emitter materials as necessary in the process), so there may be some way of doing it that way. But there's not support for scripting the values of material parameters. If you know the name of the emitter material, it would be possible to write a python script to post-process the frames (the .mxs files), changing the value in each.
By JDHill
#395883
It is necessary to know which parameter to modulate, so please upload an MXM of the emitter material you are using, and/or provide information on which emitter type/luminance mode it is using, as well as the expected power range.
By JDHill
#395885
This should do what you want:
Code: Select all
#============== CHANGE THESE VARIABLES AS REQUIRED ==============

mxs_dir   = 'C:/Users/<user name>/Desktop/mxsfiles'
mat_name  = 'Emitter'
watts_min = 0
watts_max = 25

#=================  DON'T CHANGE ANYTHING ELSE  =================

import os
import sys
from pymaxwell import *

mxs_dir = os.path.normpath(mxs_dir)
if not os.path.isdir(mxs_dir):
   print('ERROR: input dir not found: %s' % mxs_dir)
   sys.exit(1)

mxs_files = getFilesFromPath(mxs_dir, '.mxs')
if not len(mxs_files):
   print('ERROR: no MXS files found: %s' % mxs_dir)
   sys.exit(1)

mxs_files.sort()
incr = (watts_max - watts_min) / float(len(mxs_files))
watts = watts_min

def read_emitter(mxs_path):
   mw = Cmaxwell(mwcallback)
   if not mw.readMXS(mxs_path):
      print('ERROR: Failed to read %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   material = mw.getMaterial(mat_name)
   if material.isNull():
      print('ERROR: Failed to find "emitter" material in %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   layer = material.getLayer(0)
   if layer.isNull():
      print('ERROR: Failed to find layer 0 for "emitter" material in %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   emitter = layer.getEmitter()
   if emitter.isNull():
      print('ERROR: Failed to find emitter for layer 0 in %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   pair,ok = emitter.getPair()
   if not ok or emitter.isNull():
      print('ERROR: Failed to get emitter pair for layer 0 in %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   return mw,emitter,pair

for mxs_file in mxs_files:
   mxs_path = os.path.join(mxs_dir, mxs_file)
   mw,emitter,pair = read_emitter(mxs_path)
   if not mw:
      continue
   pair.watts = watts
   emitter.setPair(pair)
   if not mw.writeMXS(mxs_path):
      print('ERROR: failed to write %s' % mxs_path)
   else:
      print('OK: adjusted emitter to %s in %s.' % (watts, mxs_path))
   mw.freeScene()
   watts = watts + incr
You can see near the top where you need to specify the directory where your mxs files are located, and the name of the emitter material to adjust; you can also optionally change the min/max wattage. The mxs files are sorted according to name, with ascending wattage being assigned accordingly, so it should work as expected for numbered animation frames.
User avatar
By Q2
#395928
OKAY.... ran into a little problem here with the script:

Check this out...

Uncaught exception at <anonymous script, id=1662860573264>:16: SyntaxError: Parse error
16 import os

How come he stops at line 16 ? That's where 'import os' starts

This is what I changed in your script. All MXS files that need processing are located on my Windows10 desktop and I also changed the emitter name accordingly...


//********************************************//
//********************************************//
//************* Maxwell Scripting *************//
//********************************************//
//********************************************//

//============== CHANGE THESE VARIABLES AS REQUIRED ==============//

mxs_dir = 'C:/Users/<carstenquilitz/Desktop/mxsfiles'
mat_name = '- DISPLAY HERD AKTIV'
watts_min = 0
watts_max = 500

//================= DON'T CHANGE ANYTHING ELSE =================//

import os
import sys
from pymaxwell import *

mxs_dir = os.path.normpath(mxs_dir)
if not os.path.isdir(mxs_dir):
print('ERROR: input dir not found: %s' % mxs_dir)
sys.exit(1)

mxs_files = getFilesFromPath(mxs_dir, '.mxs')
if not len(mxs_files):
print('ERROR: no MXS files found: %s' % mxs_dir)
sys.exit(1)

mxs_files.sort()
incr = (watts_max - watts_min) / float(len(mxs_files))
watts = watts_min

def read_emitter(mxs_path):
mw = Cmaxwell(mwcallback)
if not mw.readMXS(mxs_path):
print('ERROR: Failed to read %s.' % mxs_path)
mw.freeScene()
return None,None,None
material = mw.getMaterial(mat_name)
if material.isNull():
print('ERROR: Failed to find "emitter" material in %s.' % mxs_path)
mw.freeScene()
return None,None,None
layer = material.getLayer(0)
if layer.isNull():
print('ERROR: Failed to find layer 0 for "emitter" material in %s.' % mxs_path)
mw.freeScene()
return None,None,None
emitter = layer.getEmitter()
if emitter.isNull():
print('ERROR: Failed to find emitter for layer 0 in %s.' % mxs_path)
mw.freeScene()
return None,None,None
pair,ok = emitter.getPair()
if not ok or emitter.isNull():
print('ERROR: Failed to get emitter pair for layer 0 in %s.' % mxs_path)
mw.freeScene()
return None,None,None
return mw,emitter,pair

for mxs_file in mxs_files:
mxs_path = os.path.join(mxs_dir, mxs_file)
mw,emitter,pair = read_emitter(mxs_path)
if not mw:
continue
pair.watts = watts
emitter.setPair(pair)
if not mw.writeMXS(mxs_path):
print('ERROR: failed to write %s' % mxs_path)
else:
print('OK: adjusted emitter to %s in %s.' % (watts, mxs_path))
mw.freeScene()
watts = watts + incr


Cheers Q!
By JDHill
#395929
The problem should be that I did not specify, this is a python script, which you should run in pymaxwell (where you'll need to revert the changes to the comments, since python comments start with a '#' character as shown in the original script). Also note that indentation is significant in python.
User avatar
By Q2
#395930
Code: Select all
#============== CHANGE THESE VARIABLES AS REQUIRED ==============

mxs_dir   = 'C:/Users/<Carsten Quilitz>/Desktop/mxsfiles'
mat_name  = 'Emitter'
watts_min = 0
watts_max = 500

#=================  DON'T CHANGE ANYTHING ELSE  =================

import os
import sys
from pymaxwell import *

mxs_dir = os.path.normpath(mxs_dir)
if not os.path.isdir(mxs_dir):
   print('ERROR: input dir not found: %s' % mxs_dir)
   sys.exit(1)

mxs_files = getFilesFromPath(mxs_dir, '.mxs')
if not len(mxs_files):
   print('ERROR: no MXS files found: %s' % mxs_dir)
   sys.exit(1)

mxs_files.sort()
incr = (watts_max - watts_min) / float(len(mxs_files))
watts = watts_min

def read_emitter(mxs_path):
   mw = Cmaxwell(mwcallback)
   if not mw.readMXS(mxs_path):
      print('ERROR: Failed to read %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   material = mw.getMaterial(mat_name)
   if material.isNull():
      print('ERROR: Failed to find "emitter" material in %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   layer = material.getLayer(0)
   if layer.isNull():
      print('ERROR: Failed to find layer 0 for "emitter" material in %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   emitter = layer.getEmitter()
   if emitter.isNull():
      print('ERROR: Failed to find emitter for layer 0 in %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   pair,ok = emitter.getPair()
   if not ok or emitter.isNull():
      print('ERROR: Failed to get emitter pair for layer 0 in %s.' % mxs_path)
      mw.freeScene()
      return None,None,None
   return mw,emitter,pair

for mxs_file in mxs_files:
   mxs_path = os.path.join(mxs_dir, mxs_file)
   mw,emitter,pair = read_emitter(mxs_path)
   if not mw:
      continue
   pair.watts = watts
   emitter.setPair(pair)
   if not mw.writeMXS(mxs_path):
      print('ERROR: failed to write %s' % mxs_path)
   else:
      print('OK: adjusted emitter to %s in %s.' % (watts, mxs_path))
   mw.freeScene()
   watts = watts + incr
   
   
Last edited by Q2 on Thu Nov 09, 2017 4:38 pm, edited 1 time in total.
By JDHill
#395931
Please put your code inside of [code][/code] tags, so I can hopefully see the code you're actually running.

Regarding the file name, the path should not have those angle brackets, those are just indicating that you should replace them with the actual user name on your machine. The string should be what you would copy/paste from explorer, with backslashes replaced with forward slashes. And of course, it should point to the directory where you actually have your mxs files (whether that is Desktop/mxsfiles or somewhere else).
User avatar
By Q2
#395932
Well we are getting closer!!!! And thanks for the great help here!!!
Code: Select all
>>
Traceback (most recent call last):
  File "<string>", line 4, in <module>
NameError: name 'Emitter' is not defined
That's now the error message. Even though I do have an material with an emitter called Emitter in my Scene but I still get this error message...
By JDHill
#395933
That is a python error indicating improper syntax; check that you have enclosed the string 'Emitter' in quotes on line 4, and that there's no possibility that they are "smart" quotes, like you might get copy/pasting from something like Word.

We don't use Revit but you might like to try some […]

Multiple surfaces on object

I guess you are asking about chanching a material […]

New Develepments for 5.2?

Some areas that need addressing One why can't we[…]

..... help please ..... :mrgreen: