Help for new script

is it possible to write a simple script to

1 ) after selecting an object
you save all ( or Most ) the object variables on an ASCII files
Then Start the execution of an indepednant Module outside of Blender

Then from this new program it can read the ASCII files and  can change whatever content of the variables  and resave on the ASCII file


Then  when you come back to the Scritpt file 

you can read the ASCII file and change the values of the variables for the Selected object

It sounds a bit ridiculus but it would be a nice way to get a friendly window
on my PC and not have to deal with the complicated prensentation in Blender

The outside Task can then be written in wahever you wish.

tanks & Salutations

is it possible to write a simple script to

[details snipped]?

Yes.

I know that Anything is possible ect…

Can someone give me an example of this ?

Is there a list of all the variables that we can find for one object with the name use on the differente menu and in the script?

an dhow to start an external task ( XYZ.EXE )

ect…

Tanks

Untrue. The laws of thermodynamics, limitations in whatever api, language and computer platform you are using, your own motivation, etc.

Is there a list of all the variables that we can find for one object with the name use on the differente menu and in the script?

Look in the Blender Python API documentation for the details about the objects of interest.

an dhow to start an external task ( XYZ.EXE )

Look at the Python documentation. The os.system() call will be useful. Also read about file i/o.

ect…

Learn enough about Blender to save and load text files and scripts. Learn how to execute Blender scripts. Look at other scripts like the importers and exporters for examples of what you want to do.

Learn whatever programming language you are going to write the rest of the application in.

What you want do is not complicated. You just need to have some basic knowlege first.

I got fed up reading the doc -
in Python you can ask an object for its methods

  • the getters and setters.

This is often easier/quicker than reading the BPY doc…;

ObProps does this, saving the answer as a dict
that you can write in a variety of ways

There’s also a setter function that take’s the dict
and sets an objects properties.

Good luck -


import Blender
import sys

from Blender import Object,Material

def getFreshText(name):
 try:
  x = Blender.Text.Get(name)
  x.clear()
 except:
  x = Blender.Text.New(name)
 return x

def prettyPrint(dict):
 show = []
 for key,value in dict.items():
  show.append("%s = %s" %(key,value) )
 return "%s
"%'
'.join(show)



class ObProps:
 '''look for properties that have getters/setters in BPy api'''
 def __init__(self,obj):

  props ={}
  #if obj.getType != "
  getters = [x for x in dir(obj) if x[:3] == 'get']
  for method in getters:
   try: 
    exec 's = obj.%s()'%method
    props[method[3:]] =  s
   except:
    print "props warning : skipping %s"%method
  self.data = props

 def __repr__(self):
  tmp = [ (repr(a).ljust(15),repr(b).ljust(25)) for a,b in self.data.items()]
  return ''.join(["%s%s
"%x for x in tmp])

 def asSetters(self):
  show = []
  for key,value in self.data.items():
   show.append("obj.set%s(%s)" %(key,value) )
  return "%s
"%'
'.join(show)

 def asDict(self):
  show = ["{"]
  for key,value in self.data.items():
   show.append("
\'%s\' : %s" %(key,value) )
   show.append(",")
  if len(show)==1:
   show.append("}
")
  else:
   show[-1] = "
}
"
  return "".join(show)

 
def exportIpo(ipo):
 exportDict ={}
 exportDict['Name'] = ipo.getName()

 cvs = {}
 for posCv,cv in enumerate(ipo.getCurves()):
  
  #dd['Extrapolation'] = cv.getExtrapolation()
  pts = []
  for x in cv.getPoints():
	y = x.getPoints()
  	pts.append((y[0],y[1]))
  cvs[cv.getName()] = pts
 exportDict['Curves'] = cvs
 return exportDict

def printIpo(dict):
 xx = ["%sIpo = {"%dict['Name'],]
 for name,pts in dict["Curves"].items():
  xx.append('''"%s" :  '''%name)
  ptStr = ["["]
  for a,b in pts:
   ptStr.append("(%.2f,%.2f)"%(a,b))
   ptStr.append(",")
  ptStr[-1] = "]"
  xx.append("".join(ptStr))
  xx.append(",
")
 xx[-1] = "
}"
 return "".join(xx)

def matData(name):
 mat= Blender.Material.Get(name)
 fp = getFreshText('%sdata.py'%name)
 fp.write("_%sDict="%name)
 fp.write(ObProps(mat).asDict())

def ipoData(name):
 mipo = Blender.Ipo.Get(name)
 fp = getFreshText('%sIpoData.py'%name)
 fp.write(ObProps(mipo).asDict())

def partsData(name):
 parts = Blender.Effect.Get(name)[0]
 fp = getFreshText('%sPartData.py'%name)
 fp.write(ObProps(parts).asDict())

def setFromDict(obj,dict):
 for a,b in dict.items():
  try:
   eval("obj.set%s(%s)"%(a,repr(b)))
  except:
   print "WARNING : setFromDict failed to set %s"%a

def dictFromMtex(mtex):
 dict = {}
 for var in dir(mtex):
  if var[:2] !="__" and var not in ["setTex", "tex"]:
	dict[var] = eval("mtex.%s"%var)
 return dict

obj = Blender.Object.GetSelected()[0]

print ObProps(obj).asDict()