card = getattr(nuke.nodes, cardClass)()

Although it would probably be more straightforward (and easier to read) if
you just create one or the other in your if-else statement?

if (type=='card') | (type=='Card'):
     card = nuke.nodes.Card2()
elif (type=='card3D') | (type=='Card3D'):
     card = nuke.nodes.Card3D()

Cheers,
Ivan

On Wed, Jul 6, 2011 at 2:38 PM, j00ey <[email protected]>wrote:

> **
> Hi all
> I'm starting out in python so this is very simple one. I'm trying to write
> a simple proc that will create a Card or a Card3D depending on user input. I
> can get it to work with nuke.createNode but if the current selection is eg a
> read node the card gets connected to it which I don't want.
>
> I know I can create an unconnected node with eg nuke.nodes.Card2() but I
> want to pass user input as the class and I can't figure out the syntax.
>
> Can anyone help? Thanks in advance.
>
>
> ##query user for Card or Card3D
>
> type=nuke.getInput('Card or Card3D','Card')
>
> if (type=='card') | (type=='Card'):
> cardClass='Card2'
> elif (type=='card3D') | (type=='Card3D'):
> cardClass='Card3D'
>
> #card=nuke.createNode(cardClass)
> card=nuke.nodes...
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to