[Smtk-developers] SMTK in Python

David Thompson david.thompson at kitware.com
Mon Dec 1 14:23:33 EST 2014


Hi all,

I have noticed a recurring pattern to the Python model-operator tests and think there is space for a "simple" API (like paraview.simple) for model operations. If there's nothing else on the agenda for our meeting tomorrow, I'd like to put this on the agenda.

Many of the tests have blocks of Python that look like this:

cb = sess.op('create brick')
ov = cb.findAsInt('construction method')
ov.setDiscreteIndex(0)
ctr = cb.findAsDouble('center')
setVector(ctr, [1., 0., 0.])
cb.findAsDouble('width').setValue(0.5)
res = cb.operate()

Really, all of these lines could be simplified to something like:

result = sess.operate('create brick', \
  {'construction method':0, \
   'center': [1., 0., 0.], \
   'width':0.5})

Are there objections to adding a Python function that does this to smtk.py? Should I do like ParaView and make an smtk.simple submodule? Suggestions for improvements? I can see one issue is that if the "construction method" item above isn't the first one set, the "width" item won't be active (so all children would have to be searched, not just the active children).

The method above is specific to operators, but in general it seems like a more concise method for creating and setting attributes is possible. 

	Thanks,
	David


More information about the Smtk-developers mailing list