Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Loading IES Files into Light Objects?

    Scheduled Pinned Locked Moved PYTHON Development
    8 Posts 0 Posters 762 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 16/10/2015 at 15:44, xxxxxxxx wrote:

      Hi,

      I'm attempting to write a SceneLoaderData plugin for IES files that automatically adds them as new light objects to the scene. I'm able to successfully create a light object, set it's type to Photometric, and load in the IES file, however loading the IES file programmatically doesn't auto-fill the Photometric Intensity and Luminaire information as happens when you manually load the IES file in C4D.

      Here's the code I'm using to load the IES files into a new light:

        
              light = c4d.BaseObject(c4d.Olight)   
              light_bc = light.GetDataInstance()   
              doc.InsertObject(light)   
              light[c4d.LIGHT_TYPE] = c4d.LIGHT_TYPE_PHOTOMETRIC   
              light[c4d.LIGHT_PHOTOMETRIC_DATA] = True   
              light_bc.SetFilename(c4d.LIGHT_PHOTOMETRIC_FILE, name)   
      

      I'd rather not write my own IES parser to get at this information. Any recommendations on how to get C4D to auto-extract the info from the IES file?

      When C4D does it:

      When I do it:

      Thanks,

      Donovan

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 16/10/2015 at 22:18, xxxxxxxx wrote:

        Hello
        I only get preview by set levels

        http://imhocloud.com/image/7yeQ

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 19/10/2015 at 04:41, xxxxxxxx wrote:

          Hi Donovan,

          for internal reasons you need to use SetParameter() with DESCFLAGS_SET_USERINTERACTION flag to set the IES filename.
          Like so:

          light.SetParameter(c4d.LIGHT_PHOTOMETRIC_FILE, iesFile, c4d.DESCFLAGS_SET_USERINTERACTION)
          
          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 19/10/2015 at 05:31, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            for internal reasons you need to use SetParameter() with DESCFLAGS_SET_USERINTERACTION flag to set the IES filename.
            Like so:

            light.SetParameter(c4d.LIGHT_PHOTOMETRIC_FILE, iesFile, c4d.DESCFLAGS_SET_USERINTERACTION)
            

            I can't resist to thank you.
            Some time ago i used it but with _c4d.DESCFLAGS_SET_0

            _ Interesting, does it need to update c4d/AM after set parameter _, by c4d.SendCoreMessage(c4d.COREMSG_CINEMA, c4d.BaseContainer(c4d.COREMSG_CINEMA_FORCE_AM_UPDATE))Question
            _

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 19/10/2015 at 09:04, xxxxxxxx wrote:

              @Andreas - Thanks so much, that did the trick! Is there any rule of thumb for when I should use "SetParameter" over one of the other methods like SetFilename or the more simple "light[c4d.LIGHT_PHOTOMETRIC_FILE] = file"?

              Here's the code I'm using now:

                
                      light = c4d.BaseObject(c4d.Olight)   
                      ies_file_name = os.path.splitext(os.path.basename(name))[0]   
                      light.SetName("IES Light: " + ies_file_name);   
                      doc.InsertObject(light)   
                      light[c4d.LIGHT_TYPE] = c4d.LIGHT_TYPE_PHOTOMETRIC   
                      light.SetParameter(c4d.LIGHT_PHOTOMETRIC_FILE, name, c4d.DESCFLAGS_SET_USERINTERACTION)   
                      light.Message(c4d.MSG_CHANGE)   
              
              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 19/10/2015 at 09:05, xxxxxxxx wrote:

                Also, thank you @Ilya for your help as well!

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 19/10/2015 at 09:11, xxxxxxxx wrote:

                  Hi Donovan,

                  well, the rule of thumb is, you should always prefer SetParameter() or in Python the equivalent obj[descid] over accessing the BaseContainer directly (GetDataInstance(), bc[id]), because in the later case you somewhat bypass the object, which can not react on the parameter modification (in its SetDParameter() function). And not every object stores everything in the BaseContainer, then of course the container access fails completely. See also the thread Set light intensity from Python.

                  In your case, you have to use SetParameter() instead of obj[] in order to pass the user interaction flag, of course.

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    On 20/10/2015 at 17:02, xxxxxxxx wrote:

                    I started with the __get__ / __set__ methods, but didn't get the result I was after, at which point I moved to GetDataInstance(). Thanks for more context, that gives me a better sense of how to approach this in the future.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post