Reloading Dialog??

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

On 12/12/2012 at 08:06, xxxxxxxx wrote:

Trying to build a custom tool with the GeDialog functions inside a script instead of a plugin. The problem is I have to close and reopen C4D if I want to see any updates to the Dialog for some reason. Not sure why.

Tried importing script as a module, but C4D won't recognize the script as a module either; so reload() is out of the question I guess.

Is there a reload function I am not seeing here in the help docs?

Thanks for the help.

Rick

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

On 12/12/2012 at 08:46, xxxxxxxx wrote:

I didn't understand where you are building the dialog. In a separate file?

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

On 12/12/2012 at 12:52, xxxxxxxx wrote:

Originally posted by xxxxxxxx

Tried importing script as a module, but C4D won't recognize the script as a module either; so reload() is out of the question I guess.

i am also not quite sure what you do mean, but you are aware of sys.path or  modules folder 
at user/blahblah/ ... Cinema4d/... blah ... /python/modules ? you can't add modules add 
runtime,  but you can for sure create a Desktop/myModule.py and use it in c4d, you have just 
add the Desktop to your sys.path list.

http://docs.python.org/2/library/sys.html#sys.path

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

On 12/12/2012 at 13:05, xxxxxxxx wrote:

Sorry I am building the Dialog inside the Script Manager and saving it out to the scripts folder for C4D.

Importing, reloading and running with the following syntax:

import [script name]
reload[script name]
script name . run function

I just keep getting an error saying 'No module named [script name here]'. Coming from the scripting world in Maya, this was all I ever had to do, was save it inside the scripts folder. I am going to look into the sys.path stuff more though, I just figured it would be built in for C4D to read modules from its own scripts folder.

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

On 12/12/2012 at 13:36, xxxxxxxx wrote:

it is still not 100% clear to me what you want. since you are talking about modules, 
i assume you are talking about multiple files. lets assume you have got 2 files.

c://myModule.py
myScriptfile.py

myScriptfile.py doens't have to be physically on your hardrive you can also create just in
the memory within the document. the import statements for myScriptfile.py would be :

import sys, os
__mypath__ = 'c:\\'
if __myPath__ not in sys.path: sys.path.insert(0, __myPath__)
  
import c4d, myModule
...

however, i am 100% sure one of the more experienced guys here will come arround 
and tell us, that absolute paths are bad. so normally you would do something like that :

import sys, os
# that line is just working in a script/tag or node, for a plugin we had to use c4d.documents 
# and so o. also the document has to be saved at leasst once, otherwise doc.GetDocumentPath()
# will be "".
if doc.GetDocumentPath() not in sys.path: sys.path.insert(0, doc.GetDocumentPath())
  
import c4d, myModule
  
or like this
  
__currdir__ = os.path.join(os.path.dirname(__file__) , 'modules')
if __currdir__ not in sys.path: sys.path.insert(0, __currdir__)
  
import c4d, myModule

you can also just drop the script into the c4d usersettings python modules folder.

ps : also note that python sometimes needs a __init__.py file (no content)
in the folder you want to become a module folder. i also never understood when 
they have to be created and when not, so i just drop them here and there :)

pps: just to make it really clear. myModule.py has to exist before c4d has been started.
Any changes made to myModule.py while C4d is running , won't take any effect before 
C4D has been restarted again.