Wiretap

Reply
Contributor
panisset
Posts: 14
Registered: ‎01-15-2003
Message 1 of 5 (222 Views)

beginner python question: WT #defines?

222 Views, 4 Replies
04-02-2007 08:47 PM
I have a beginner Python question: let's say I'm traversing the hierarchy, I've got a node object and I want to figure out its type:

typeInt = WireTapInt()
node.getNodeType( typeInt )
if typeInt == IFFFS_WT_TYPE_CLIP:
do something

But IFFFS_WT_TYPE_CLIP is an anonymous enum from ifffsWTTypes.h, how to I access that in Python code? I'd rather avoid hardcoding "6" instead of IFFFS_WT_TYPE_CLIP, and calling:

name = wireTapStr()
parent.getNode( name )
if name == "CLIP":
do something

doesn't seem much better. It looks like you are using boost.python to export the C++ API to Python, and from the brief Googling I've done, it is possible to export C++ enums that way, but I can't find any info on how to access these enum values?
Distinguished Contributor
dlabute
Posts: 103
Registered: ‎05-11-2004
Message 2 of 5 (222 Views)

Re: beginner python question: WT #defines?

04-03-2007 08:28 PM in reply to: panisset
Hi J-F,

We are deprecating the use of integer/enum node types (for this very reason), in favour of string representations. We want to avoid having to include a header for a given server, as well as make the code a bit easier to read.

The API calls you are using will remain for a few versions, and will then be removed.

Dan
Contributor
panisset
Posts: 14
Registered: ‎01-15-2003
Message 3 of 5 (222 Views)

Re: beginner python question: WT #defines?

04-03-2007 10:40 PM in reply to: panisset
It would be great if the Python DSO would export string variables containing those strings, so that I can reference a variable name instead of hard-coding a string in my Python code. That gives me a bit of "compile-time" checking, as opposed to failing at runtime because I made a typo in a string being passed to the API.
Distinguished Contributor
dlabute
Posts: 103
Registered: ‎05-11-2004
Message 4 of 5 (222 Views)

Re: beginner python question: WT #defines?

04-04-2007 05:18 AM in reply to: panisset
Right.

Part of the reason we don;t have these is because the API you have is essentially generic (i.e. no IFFFS-isms). IFFFS is not the only product to be exposed by WT. To do what you are asking, we would need a companion DSO from each of the WT-capable products.
Contributor
panisset
Posts: 14
Registered: ‎01-15-2003
Message 5 of 5 (222 Views)

Re: beginner python question: WT #defines?

04-04-2007 05:25 AM in reply to: panisset
That sounds like a reasonable approach: just provide a helper DSO for different applications which you can link again/dlopen() if you want the additional convenience/safety of not hard-coding these strings in your app.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!