med python binding

Posted By: ventilator

med python binding - 05/02/04 22:35

i started to do a python binding for med.

med_python.zip ~ 50kb

it's still very incomplete and a bit buggy (don't try to close med while the python window is open! ). currently only the vertex and triangle commands are wrapped but some things can already be done with it. ...

the latest python and wxpython release has to be installed on your pc.

-> http://www.python.org
-> http://wxpython.sourceforge.net
Posted By: Helghast

Re: med python binding - 05/02/04 23:14

sorry to be such a n00b...
but what is python, and what does it do?
Posted By: ventilator

Re: med python binding - 05/02/04 23:16

python is a scripting language. writing med plugins with python is more fun than with c++.
Posted By: Helghast

Re: med python binding - 05/02/04 23:28

ok thanks...
although i cant write plugins, seems good:D
Posted By: ventilator

Re: med python binding - 05/04/04 03:16

did anyone try it?

i fixed error redirecting and wrapped more functions. error messages get written into the file <error.txt> at the moment. you can look into it to find out what you did wrong in your scripts. ...in later versions it would be cool to have some kind of interactive script editing and message window...
Posted By: Cellulaer

Re: med python binding - 05/04/04 05:16


What version of MED started supporting plugins (I must really need to upgrade to A6)? As far as writing my own plugins in it, I know about as much Python as C++.
Posted By: ventilator

Re: med python binding - 05/04/04 05:23

i think you will need the med which comes with 6.2!

python is very easy to learn:

http://www.ibiblio.org/obp/thinkCSpy/
http://www.python.org/doc/2.3.3/tut/tut.html

here is an example of the latest plugin i did for testing:

Code:

import __main__,math,string,med

def fatman_plugin(_p_):
dlg=__main__.wx.TextEntryDialog(__main__.frame,
"this plugin adds the scaled normal to each selected vertex.\n\nnormal scale factor:",
"fatman","10")
if dlg.ShowModal()==__main__.wx.ID_OK:
values=string.split(dlg.GetValue())
fatman(float(values[0]))
dlg.Destroy()
__main__.frame.Close()

def fatman(normalscale):

med.startmodelediting()

num_vertices=med.vertex_getvertexcount()
for i in range(0,num_vertices):
med.vertex_selectvertex(i)
if med.vertex_isselected():
pos1,pos2=med.vertex_getvertexpos()
normal=med.vertex_getnormal()
pos=(pos2[0]+(normal[0]*normalscale),
pos2[1]+(normal[1]*normalscale),
pos2[2]+(normal[2]*normalscale))
med.vertex_setvertexpos(pos)

med.donemodelediting()



__main__.register_plugin("fatman",fatman_plugin) #plugin_name,plugin_function



the problem is that i am a pretty poor c/c++ programmer and i am not sure if i did everything right with the binding.
Posted By: sr124

Re: med python binding - 06/18/05 00:21

I cannot download the above link now. Could you help? It's very interesting Thanks.
Posted By: FeiHongJr

Re: med python binding - 06/18/05 01:04

get a 404 error , sounds interesting tho
Posted By: Alkai

Re: med python binding - 06/20/05 12:43

What is possible with a python plugin? What can be done with it?
Posted By: fogman

Re: med python binding - 06/20/05 21:17

Please fix this link, it sounds like
an awesome contribution.
My dude Leftz knows a bit phyton...

So please fix it or send it to me whatever...
We would be very glad!

I can upload it for you, too.
© 2024 lite-C Forums