CGTalk > Software > Maxon Cinema 4D
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
Thread Tools Search this Thread Display Modes
Old 09-10-2013, 02:59 PM   #1
hyper nerd
Florian Sepp
Join Date: Mar 2005
Posts: 344
run a script from within a script

Hi there,

I implemented a "save and renderbutton" into m the settings script of FS_preview_render
and after savinf the ini file I start the render script with call command. unfortunately the call command is different on different machines.
basically I just want to start a python script from within a python script.

I looked around and people say to use the os.system() command, witch (not surprisingly) is not working.

I triend to import my script:

import c4d, FS_preview_redner

... doesn't work.

I am shure this is not a dificult task to do, but unfortunately I was not able to find it in der SDK ether... so please

I need help :(

thanks a lot in advance
Old 09-10-2013, 03:15 PM   #2
NiklasR's Avatar
Niklas Rosenstein
Join Date: Jan 2011
Posts: 437
Hi Jops,

if only one part of the code differs depending on the circumstances, there is no need to create two separate scripts. This is what the if-statement is for

if use_command_1: c4d.CallCommand(COMMAND_ID_1) else: c4d.CallCommand(COMMAND_ID_2)

Out of interest, can you tell me what command differs on which machines? The change of Command IDs is rather a rare case in between C4D releases, and especially between platforms. Note that the ID of scripts is different from machine to machine, so you should not try to invoke another script via CallCommand().

To answer your actual question in case you really have to execute another script (which is usually only useful for dynamic loading of code):

def execute_script(filename): fl = open(filename, 'rb') code = compile(, filename, 'exec') scope = {'__file__': filename, '__name__': '__main__'} exec code in scope

Cinema 4D Plugin Developer | Freebies | Plugins
Old 09-10-2013, 03:43 PM   #3
hyper nerd
Florian Sepp
Join Date: Mar 2005
Posts: 344
Hi Niklas,

what would I do without you

even though I had the idea this coud be bad I used CallCommand() ... well stupid, I know. but I was tired and it worked for me

the reason I want to start the second script is this. I have preview render and preview settings as two scripts.
they have different icons and this makes sense as you do not want to always click twice if you could click just once

there might be a posibility to to have two icons and just one script, but back in the days I just coded it that way.

with the new version I wanted to implement this "save and render" Button, so if you change settings you don't have to hit ok (save) and then hit the icon for the render script.

your solution works nice (as always)
after helping me so many times at least 20% of this script is yours

again thanks so much.
and best regards

Old 09-10-2013, 03:43 PM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 06:27 AM.

Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.