c4d_symbols.h Parser for Py4D

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 09/06/2011 at 07:14, xxxxxxxx wrote:

Header File parser for Py4D - BETA
- - - - - - - - - - - - - -

I was sick including the ID's for a dialog created in ResEdit myself into
Python. Therefore I wrote a Header File parser. It will only analyze an
enum statement.

First, download the package below and copy the folder to your Py4D library.
In your plugin, use this code to parse the c4d_symbols.h and insert
the ID's into the global scope.

  
from    HeaderFileParser        import parse  
from    os.path                 import join, abspath, dirname  
  
parse(  
  join(  
      dirname( abspath(__file__)),  
      "res",  
      "c4d_symbols.h",  
  ),  
  globals(),  
)

You can now use the ID's defined in c4d_symbols.h in you Plugin.

Remember, this is still BETA. If any problems occure, please report it !
As this is still BETA, you might only use this while you are still
developing your plugin and your GUI might change.

HeaderFileParser_BETA_0.9

Cheers,
Niklas

//Link fixed

EDIT: The c4dtools library now does this for you!

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/08/2011 at 11:30, xxxxxxxx wrote:

I'd suggest the following use:

class foo: 'Just to store data'  
res = foo()  
from HeaderFileParser import parse  
parse(path_to_c4d_symbols_h, res.__dict__)

This will copy all ID's as attributes to the foo-instance and you can use them like this:

res.MY_ID

To replace the HeaderFileParser (for example to release the plugin and to be independent from it), you can print the dictionary that contains the IDs and copy the output into your plugin like this:

print res.__dict__

... Copy the output to clipboard, comment out the code from the HeaderFileParser and do

  
class foo: 'Just to store data'  
res = foo()  
# # # # # # # # # # # # # # # # # # # # # # # #  
# # from HeaderFileParser import parse  
# # parse(path_to_c4d_symbols_h, res.__dict__)  
# # # # # # # # # # # # # # # # # # # # # # # #  
res.__dict__ = {'MY_ID': 10023, ...} # the output pasted from the clipboard