I was sure I tried this, but I tried this again right now and...
IT WORKS!

Not sure who and how long you guys are following this thread, but I've been
taring hairs out on and off for months on this thing. Apparently, the whole
RegEx thing worked too, it was just this problem that made my script not
work. The callback.

Anyway, I'll finish off this script with a few more things I want to add to
it, and I'll publish.

Thanks Ivan and everyone else who helped.
Ron Ganbar
email: [email protected]
tel: +44 (0)7968 007 309 [UK]
     +972 (0)54 255 9765 [Israel]
url: http://ronganbar.wordpress.com/



On 7 July 2012 19:58, Ivan Busquets <[email protected]> wrote:

> Right, so looking at your AE_to_Nuke.py file, it seems like you're already
> adding the callback in there, which will be executed by the time you import
> the module, so there's no need to re-add it in your menu.py.
>
> There's another namespace issue with that setup. In AE_to_Nuke.py, you're
> calling nukescripts.addDropDataCallback, but never importing nukescripts.
>
> By the looks of it, if your script works when you run it from the script
> editor, you'll just need to add an "import nukescripts" to
> your AE_to_Nuke.py, and then simply "import AE_to_Nuke" in your menu.py
>
> Again, this is untested (away from my main computer atm), but it's the
> only thing that stands out to me by looking at that script.
>
> Cheers,
> Ivan
>
>
> On Sat, Jul 7, 2012 at 9:10 AM, Ron Ganbar <[email protected]> wrote:
>
>> Hi Ivan,
>> I carried on looking after sending the email and I noticed that too, and
>> changed it, but it didn't help.
>> Any other ideas will be welcome!
>>
>> Cheers,
>>
>> Ron Ganbar
>> email: [email protected]
>> tel: +44 (0)7968 007 309 [UK]
>>      +972 (0)54 255 9765 [Israel]
>> url: http://ronganbar.wordpress.com/
>>
>>
>>
>> On 7 July 2012 18:44, Ivan Busquets <[email protected]> wrote:
>>
>>> Sounds like a namespace problem?
>>> You're importing AE_to_Nuke, but not using that namespace when adding
>>> AE_drop to the drop callbacks, so it doesn't know where AE_drop lives.
>>>
>>> You should do:
>>> nukescripts.addDropDataCallback(AE_to_Nuke.AE_Drop)
>>>
>>> Or:
>>> from AE_to_Nuke import *
>>>
>>> ... to import its contents into the main namespace.
>>>
>>> PS. Haven't tested the actual script. Just going by what it looks like
>>> from your description, so there might be other problems.
>>>
>>> Hope that helps.
>>>
>>> Cheers,
>>> Ivan
>>>  On Jul 7, 2012 8:20 AM, "Ron Ganbar" <[email protected]> wrote:
>>>
>>>> Hi Pete,
>>>> thanks for the suggestion, but I would prefer to have it work with the
>>>> dropData callback. It just makes life a hell of a lot easier when working
>>>> with both AE and Nuke to be able to copy in one application and paste in
>>>> another.
>>>>
>>>> Anyway, I got it all to work but only using the script editor. There's
>>>> something I'm doing wrong when adding things to my menu.py, I guess.
>>>> If you try to run the attached .py file in the script editor with the
>>>> following line added right at the end:
>>>> nukescripts.addDropDataCallback( AE_Drop )
>>>> Everything will work great.
>>>>
>>>> What I did is:
>>>>
>>>>    1. place the AE_to_Nuke file in my .nuke folder
>>>>    2. Added 'import AE_to_Nuke' at the top of my menu.py
>>>>    3. Added 'nukescripts.addDropDataCallback( AE_Drop )' at some point
>>>>    below that above line in my menu.py.
>>>>
>>>> Restarted Nuke.
>>>> Now instead of getting my Transform node like I do if I run my script
>>>> from the script editor, I get a syntax error 0.
>>>> I'm pulling hair here.
>>>> Something about how I'm implementing the callback, rather than the
>>>> script, I guess.
>>>> Can anybody make any sense of this?
>>>>
>>>> Ron Ganbar
>>>> email: [email protected]
>>>> tel: +44 (0)7968 007 309 [UK]
>>>>      +972 (0)54 255 9765 [Israel]
>>>> url: http://ronganbar.wordpress.com/
>>>>
>>>>
>>>>
>>>> On 7 July 2012 04:10, Pete O'Connell <[email protected]> wrote:
>>>>
>>>>> Hi Ron I think by using the clipboard and drop data you are making
>>>>> things more difficult than they need be. Why not just save your AE data as
>>>>> an AE transform data txt file then have a modified version of your
>>>>> script create a .nk file containing the Transform node (by parsing the AE
>>>>> file). This is much easier for debugging and you can drop it in Nuke
>>>>> without any explicit code.
>>>>>
>>>>> Pete
>>>>>
>>>>>
>>>>> On Fri, Jul 6, 2012 at 12:35 AM, Ron Ganbar <[email protected]> wrote:
>>>>>
>>>>>> So, I finished this script again.
>>>>>> This time instead of using RegEx I used line parsing as suggested by
>>>>>> several of you and presented by Pete.
>>>>>>
>>>>>> But again, I have the same problem.
>>>>>> When reading the text from a file - no problem what so ever. The
>>>>>> script works.
>>>>>> When reading the text from the clipboard the raw text
>>>>>> looks completely different, and I can't figure it out. I have \\n and \\t
>>>>>> everywhere, instead of \n and \t like I do when I read from file.
>>>>>>
>>>>>> Can anyone suggest how to approach fixing this? I can't figure out
>>>>>> how to get rid of \\t, for example. You can't go string.replace('\\', 
>>>>>> '\'),
>>>>>> for example.
>>>>>>
>>>>>>  I'm attaching two versions of the script (one that reads from a txt
>>>>>> file and another that reads from the clipboard) and the source After
>>>>>> Effects text.
>>>>>>
>>>>>> Thanks in advance!
>>>>>>
>>>>>>
>>>>>> Ron Ganbar
>>>>>> email: [email protected]
>>>>>> tel: +44 (0)7968 007 309 [UK]
>>>>>>      +972 (0)54 255 9765 [Israel]
>>>>>> url: http://ronganbar.wordpress.com/
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 4 July 2012 13:35, Ron Ganbar <[email protected]> wrote:
>>>>>>
>>>>>>> I ended up using readlines()
>>>>>>> Does the trick.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Ron Ganbar
>>>>>>> email: [email protected]
>>>>>>> tel: +44 (0)7968 007 309 [UK]
>>>>>>>      +972 (0)54 255 9765 [Israel]
>>>>>>> url: http://ronganbar.wordpress.com/
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 4 July 2012 12:55, John RA Benson 
>>>>>>> <[email protected]>wrote:
>>>>>>>
>>>>>>>> **
>>>>>>>> just for fun ;)
>>>>>>>>
>>>>>>>> import re
>>>>>>>> re.split('[\r\n]', txtToSplit)
>>>>>>>>
>>>>>>>> jrab
>>>>>>>>
>>>>>>>>
>>>>>>>> Ron Ganbar wrote:
>>>>>>>>
>>>>>>>> Hi guys,
>>>>>>>> thanks again for all the help in this.
>>>>>>>> I'm finally persuaded to let RegEx go.
>>>>>>>>
>>>>>>>> Pete, in your script you are splitting the text with "\r" however,
>>>>>>>> if I remember correctly on a Mac it won't be "\r" it will be "\n". Is 
>>>>>>>> there
>>>>>>>> a way to include both? Is there some code that covers both cases?
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Ron Ganbar
>>>>>>>> email: [email protected]
>>>>>>>> tel: +44 (0)7968 007 309 [UK]
>>>>>>>>      +972 (0)54 255 9765 [Israel]
>>>>>>>> url: http://ronganbar.wordpress.com/
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On 27 June 2012 02:46, Nathan Rusch <[email protected]>wrote:
>>>>>>>>
>>>>>>>>>   Alright, here�s a quick and slightly dirty take on using
>>>>>>>>> regexps that works for pasted text data. I didn�t take the time to
>>>>>>>>> implement proper value rescaling and translation into Nuke image
>>>>>>>>> coordinates; all keys are just set straight from the raw values from 
>>>>>>>>> AE.
>>>>>>>>>
>>>>>>>>> Again, I would still advocate for a regexp-free approach to this,
>>>>>>>>> but hope it helps somehow.
>>>>>>>>>
>>>>>>>>> -Nathan
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  *From:* Nathan Rusch <[email protected]>
>>>>>>>>> *Sent:* Monday, June 25, 2012 11:27 AM
>>>>>>>>>  *To:* Nuke Python discussion<[email protected]>
>>>>>>>>> *Subject:* Re: [Nuke-python] AE Transform to Nuke
>>>>>>>>>
>>>>>>>>>    Without having taken a really close look at the structure of
>>>>>>>>> your function yet, here are a couple immediate things to try:
>>>>>>>>>
>>>>>>>>> 1) Split your data into lines before you process it.
>>>>>>>>> 2) Recompiling your regex objects inside a loop is pretty
>>>>>>>>> inefficient. The point of compiling regexps is so they can be reused
>>>>>>>>> multiple times, and you typically just want to compile them all one 
>>>>>>>>> time
>>>>>>>>> each at highest level that makes sense, which in this case would 
>>>>>>>>> probably
>>>>>>>>> be the module level.
>>>>>>>>> 3) Rather than explicitly matching tab characters, just use the \s
>>>>>>>>> token, which will match any kind of whitespace. This goes hand in 
>>>>>>>>> hand with
>>>>>>>>> initially splitting your data into lines, since it will prevent your
>>>>>>>>> regexps from accidentally matching across multiple lines.
>>>>>>>>>
>>>>>>>>> I�ll take a closer look after work.
>>>>>>>>>
>>>>>>>>> -Nathan
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  *From:* Ron Ganbar <[email protected]>
>>>>>>>>> *Sent:* Monday, June 25, 2012 11:15 AM
>>>>>>>>> *To:* Nuke Python discussion<[email protected]>
>>>>>>>>> *Subject:* Re: [Nuke-python] AE Transform to Nuke
>>>>>>>>>
>>>>>>>>>  Hi Wouter,
>>>>>>>>> I tried this kinda thing for the regex strings:
>>>>>>>>> regex =
>>>>>>>>> re.compile('\\t+([-+]?\d+\.?\d*)\\t+([-+]?\d+\.?\d*)\\t+([-+]?\d+\.?\d*)\\t+([-+]?\d+\.?\d*)\\t+')
>>>>>>>>>
>>>>>>>>> Didn't help (though testing the string in pythonregex.com does
>>>>>>>>> show results).
>>>>>>>>>
>>>>>>>>> If I did it wrong I'd love to know. Any other ideas welcome too.
>>>>>>>>>
>>>>>>>>> Thanks!
>>>>>>>>> Ron Ganbar
>>>>>>>>> email: [email protected]
>>>>>>>>> tel: +44 (0)7968 007 309 [UK]
>>>>>>>>>      +972 (0)54 255 9765 [Israel]
>>>>>>>>> url: http://ronganbar.wordpress.com/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 25 June 2012 21:05, Ron Ganbar <[email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Wouter,
>>>>>>>>>> thanks. That's something I haven't tried.
>>>>>>>>>> I'll have a look.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Ron Ganbar
>>>>>>>>>> email: [email protected]
>>>>>>>>>> tel: +44 (0)7968 007 309 [UK]
>>>>>>>>>>      +972 (0)54 255 9765 [Israel]
>>>>>>>>>> url: http://ronganbar.wordpress.com/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>   On 25 June 2012 20:15, Wouter Klouwen 
>>>>>>>>>> <[email protected]>wrote:
>>>>>>>>>>
>>>>>>>>>>> On 19/06/2012 08:28, Ron Ganbar wrote:
>>>>>>>>>>>
>>>>>>>>>>>> The weird thing is that the code I have works perfectly when
>>>>>>>>>>>> reading the
>>>>>>>>>>>> text from a text file, just not when reading from paste. Really
>>>>>>>>>>>> annoying
>>>>>>>>>>>> to start and write it again from scratch. Plus, I would love to
>>>>>>>>>>>> have
>>>>>>>>>>>> learned from this script something useful about re.
>>>>>>>>>>>> Any chance you can have another look?
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  Your regexps look very strict. I would suggest to be more
>>>>>>>>>>> permissive in the amount and kind of whitespacing you allow between 
>>>>>>>>>>> numbers.
>>>>>>>>>>> I would suggest:
>>>>>>>>>>>
>>>>>>>>>>> [:blank:]+  instead of \t
>>>>>>>>>>>
>>>>>>>>>>> Or if the Python regexps don't support he POSIX character
>>>>>>>>>>> classes, just [ \t]+.
>>>>>>>>>>>
>>>>>>>>>>> It's entirely possible that you're getting spaces in the pasted
>>>>>>>>>>> data instead of the tabs read from file.
>>>>>>>>>>>
>>>>>>>>>>> HTH,
>>>>>>>>>>>    Wouter
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Wouter Klouwen, Software Engineer
>>>>>>>>>>> The Foundry, 6th Floor, Comms Building, 48 Leicester Sq, London
>>>>>>>>>>> WC2H LT
>>>>>>>>>>> Tel: +442079686828 � Fax: +4420 79308906 � thefoundry.co.uk
>>>>>>>>>>> The Foundry Visionmongers Ltd � Reg.d in England and Wales No:
>>>>>>>>>>> 4642027
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> 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
>>>>>>>>>
>>>>>>>>>  ------------------------------
>>>>>>>>> _______________________________________________
>>>>>>>>> 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
>>>>>>>>>
>>>>>>>>>
>>>>>>>>  ------------------------------
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Nuke-python mailing [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
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>
>>>
>>
>> _______________________________________________
>> 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
>
>
_______________________________________________
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