CGTalk > Software > Maxon Cinema 4D
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 08-17-2013, 01:41 PM   #1
dennishmiller
Expert
 
Join Date: Aug 2004
Posts: 262
Import gradients?

Some time ago there was a shader that could import gradient files in Gimp (.ggr) format. Does anyone know if there is anything available for R13 that can do the same or any other way to import a gradient? Thanks for any info.
Dennis
 
Old 08-17-2013, 03:43 PM   #2
littledevil
Meh
 
littledevil's Avatar
portfolio
Ferdinand
Germany
 
Join Date: Aug 2002
Posts: 616
i do not have gimp installed here, but the gimp gradient format is pretty easy to read, as
it is pure ascii. most likely you will have to tinker around with script, but it will give you
a general direction and the result looks okish. the script will ask for a gradient file and tries
to make any sense of the files contents. it does return the gradient as a userdata
gradient in a null object.


code : http://codepad.org/EgceNTKb

i have tested it with the first gradient in the collection you can find here :

http://fc07.deviantart.net/fs51/i/2...pe_by_nevit.png
http://nevit.deviantart.com/art/900...scape-103771340

as i said, it is just a starter, the gradient file format did change with gimps development,
also the approach does not take account for gradient files holding multiple gradients (which
is possible i think). also the code is lacking any form of comments and exception/error
handling.
__________________
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.

Last edited by littledevil : 08-17-2013 at 03:47 PM.
 
Old 08-17-2013, 03:55 PM   #3
littledevil
Meh
 
littledevil's Avatar
portfolio
Ferdinand
Germany
 
Join Date: Aug 2002
Posts: 616
just added 3 lines to read in also the preset name, which does make it more convenient if
you want to read more presets.

http://codepad.org/cmxXV1l7
__________________
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.
 
Old 08-17-2013, 04:00 PM   #4
dennishmiller
Expert
 
Join Date: Aug 2004
Posts: 262
Import gradients

Thanks for the effort on this. I"m afraid my coding skills aren't up to the task - will this compile into a shader or a dialog in the Gradient window to import the file? Would you have a sec to send over a compiled version?
Thanks again - looks like this will do it.
d.


Quote:
Originally Posted by littledevil
just added 3 lines to read in also the preset name, which does make it more convenient if
you want to read more presets.

http://codepad.org/cmxXV1l7
 
Old 08-17-2013, 04:11 PM   #5
littledevil
Meh
 
littledevil's Avatar
portfolio
Ferdinand
Germany
 
Join Date: Aug 2002
Posts: 616
it is a python script, so there is nothing to compile at all. the script will open a file dialog asking
for the gimp gradient file. if the given file does make any sense the script will insert a null object into you scene holding the gradient data. then you can copy paste the gradient data to any location you want. the approach is necessary, as it is neither possible to get hold of description selection information in the c4d api nor is it possible to write datatype data into the clipboard with the python api.
__________________
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.
 
Old 08-18-2013, 02:40 AM   #6
dennishmiller
Expert
 
Join Date: Aug 2004
Posts: 262
Import gradinets

So should I copy the script and paste it into an ASCII file - and if so, then what extension should I use, and then do it just save it into the Scripts folder in the Library?


Quote:
Originally Posted by littledevil
it is a python script, so there is nothing to compile at all. the script will open a file dialog asking
for the gimp gradient file. if the given file does make any sense the script will insert a null object into you scene holding the gradient data. then you can copy paste the gradient data to any location you want. the approach is necessary, as it is neither possible to get hold of description selection information in the c4d api nor is it possible to write datatype data into the clipboard with the python api.
 
Old 08-18-2013, 02:53 AM   #7
dennishmiller
Expert
 
Join Date: Aug 2004
Posts: 262
gradient

Okay, I got it to Execute and then the gradient shows up in the User Data area.
So then how would I apply that to a Material?
Looks like this will be very handy.

Quote:
Originally Posted by littledevil
it is a python script, so there is nothing to compile at all. the script will open a file dialog asking
for the gimp gradient file. if the given file does make any sense the script will insert a null object into you scene holding the gradient data. then you can copy paste the gradient data to any location you want. the approach is necessary, as it is neither possible to get hold of description selection information in the c4d api nor is it possible to write datatype data into the clipboard with the python api.
 
Old 08-18-2013, 11:13 AM   #8
littledevil
Meh
 
littledevil's Avatar
portfolio
Ferdinand
Germany
 
Join Date: Aug 2002
Posts: 616
you can copy & paste every datatype in c4d. simpy RMB click on the name text of the
element you want to copy (the gradient name in the user data). select copy in the pop
up menu. in the target object/shader/tag open the popup menu for the target gradient
and select paste instead. pasting does also work with multi selections, but the cmd+c &
cmd+v hotkeys do NOT work for the datatype clipboard.

about saving the script. the natural extension would be *.py, and the place the script
folder. but in the end neither the extension, nor the folder path are mandatory. you can
also save it as a *.txt file on your desktop, the script will run just fine from there too.
__________________
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.

Last edited by littledevil : 08-18-2013 at 11:17 AM.
 
Old 08-18-2013, 01:01 PM   #9
dennishmiller
Expert
 
Join Date: Aug 2004
Posts: 262
import gradiant

Thanks so much for that - a great lesson!
Got it working now.
d.


Quote:
Originally Posted by littledevil
you can copy & paste every datatype in c4d. simpy RMB click on the name text of the
element you want to copy (the gradient name in the user data). select copy in the pop
up menu. in the target object/shader/tag open the popup menu for the target gradient
and select paste instead. pasting does also work with multi selections, but the cmd+c &
cmd+v hotkeys do NOT work for the datatype clipboard.

about saving the script. the natural extension would be *.py, and the place the script
folder. but in the end neither the extension, nor the folder path are mandatory. you can
also save it as a *.txt file on your desktop, the script will run just fine from there too.
 
Old 08-18-2013, 01:01 PM   #10
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 07:08 PM.


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