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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How can I one-click the fbx import?

    Scheduled Pinned Locked Moved PYTHON Development
    13 Posts 0 Posters 1.3k 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 03/07/2015 at 08:34, xxxxxxxx wrote:

      Thanks a lot Sebastian!!You gave me the way to find the answer!!Now I know how to configurate the import settings as the 1st POPUP window by script. But for the 2nd POPUP window that I indeed is to set the Animation Start Time and Animation End Time checked on. I have check the files that you mentioned above resource\modules\fbx\dialogs,what I understand is it is defining the UI of the popup window, not like the 1st popup window can be set the configuration like your example  fbximport[c4d.FBXIMPORT_CAMERAS] = False .I can find the 2 check script but they are just a ui script,right? 
      Could you please explaind more of that? what I need is Animation Start Time and Animation End Time be checked.

      Many thanks again!!

      Best,
      Ben

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

        On 03/07/2015 at 09:18, xxxxxxxx wrote:

        Originally posted by xxxxxxxx

        Hello,

        you cannot directly edit the import dialog of an importer or exporter. When you use MergeDocument() and don't set the SCENEFILTER_DIALOGSALLOWED flag, dialogs should not appear.

        But you can edit the settings of the importer by accessing the importer plugin. You find an example showing to do this with the Alembic Exporter.

        In the case of a FBX importer the configuration could look like this:

         
        #select a file  
        selectedFile = c4d.storage.LoadDialog(type=c4d.FILESELECTTYPE_ANYTHING, title="Choose FBX")  
         
        if selectedFile is None:  
              return  
         
        # find the FBX importer plugin  
        plug = plugins.FindPlugin(1026369, c4d.PLUGINTYPE_SCENELOADER)  
        if plug is None:  
              return  
         
        # access the settings  
        op = {}  
        if plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, op) :  
              print op  
                
              fbximport = op["imexporter"]  
              if fbximport is None:  
                      return  
                
              # define the settings  
              fbximport[c4d.FBXIMPORT_CAMERAS] = False  
         
              # import without dialogs  
              c4d.documents.MergeDocument(doc,selectedFile,c4d.SCENEFILTER_OBJECTS,None)  
         
        c4d.EventAdd()  
        

        You find the FBX settings defined in the header files of the FBX module in resource\modules\fbx\description and resource\modules\fbx\dialogs. Currently I have no FBX file with takes at hand to test your case.

        Best wishes,
        Sebastian

        Hi Sebastian, when I copy your script and add import c4d etc in a new script, it always appear this console error:KeyError: 'imexporter'. It was pointing at the line  fbximport = op["imexporter"].

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

          On 04/07/2015 at 05:35, xxxxxxxx wrote:

          Hi Sebastian,

          I just found that, if my fbx file with a take but not name "C4D Animation Take", the 2nd popup window will show up. This can help me to "kill" the 2nd popup("Select Take")window. But I still have to make sure CHECKED the  Animation Start Time and Animation End Time. Because some of my fbx files with repeat pattern keyframes, that make my importing time so long and import over million keyframes in my timeline!!! The file became a huge size!!! So is there any other way that I can cut out the keyframes after the Take when it is in import progress? Just like the same result as I checked the Animation Start Time and Animation End Time.

          I am in a ungent stage, hope can get your feedback ASAP.

          Many thanks!!!!

          Best,

          Ben

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

            On 04/07/2015 at 08:29, xxxxxxxx wrote:

            Hello,

            as said before I don't have a FBX file with takes at had so I can't test your scenario. If you want help you could provide a simple file to reproduce the issue.

            Looking at the source code it might not be possible to edit the second popup window, but without a file to test it I can't say anything more.

            Best wishes,
            Sebastian

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

              On 04/07/2015 at 12:54, xxxxxxxx wrote:

              Hello Sebastian,

              Yes, I can provide a simple fbx file.
              please find the sample file by the link below:

              https://www.dropbox.com/s/gd79ohfq3wl7sm4/cam_42_021_tql.rar?dl=0

              Thanks,
              Ben

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

                On 06/07/2015 at 07:27, xxxxxxxx wrote:

                Hi Ben,

                I'm afraid there's no way to interact by script with the "Select Take" dialog and check the Animation Start Time and Animation End Time.
                Also what version of Cinema do you use?

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

                  On 07/07/2015 at 14:53, xxxxxxxx wrote:

                  Hello, I am using R16. actually I didnot have to interact with the popup window, as long as I can setting the take start time and end time by script when importing fbx, like the script Sebastian wrote above.

                  Thanks,
                  Ben

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

                    On 08/07/2015 at 01:44, xxxxxxxx wrote:

                    Hi Ben,

                    Originally posted by xxxxxxxx

                    Hello, I am using R16. actually I didnot have to interact with the popup window, as long as I can setting the take start time and end time by script when importing fbx, like the script Sebastian wrote above.

                    I'm sorry I have not explained it well in my previous post: it's not possible to set the take start time and end time in the "Select Take" dialog by script.
                    The information shown in this dialog isn't stored in any BaseContainer.

                    Have you tried again the script Sebastian's posted? If you're using R16 it shouldn't give any error on fbximport = op["imexporter"].
                    I ran the script and opened the FBX file you provided and it's loading fine.
                    Here's the script I used:

                    import c4d
                    from c4d import plugins
                      
                    def main() :
                        # Select a file
                        selectedFile = c4d.storage.LoadDialog(type=c4d.FILESELECTTYPE_ANYTHING, title="Choose FBX")
                      
                        if selectedFile is None:
                            return
                      
                        # Find the FBX importer plugin
                        plug = plugins.FindPlugin(1026369, c4d.PLUGINTYPE_SCENELOADER)
                        if plug is None:
                            return
                      
                        # Access the settings
                        op = {}
                        if plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, op) :
                            print op
                      
                        fbximport = op["imexporter"]
                        if fbximport is None:
                            return
                      
                        # Define the settings
                        fbximport[c4d.FBXIMPORT_CAMERAS] = False
                      
                        # Import without dialogs
                        c4d.documents.MergeDocument(doc, selectedFile, c4d.SCENEFILTER_OBJECTS|c4d.SCENEFILTER_MATERIALS, None)
                      
                        c4d.EventAdd()
                      
                    if __name__=='__main__':
                        main()
                      
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      On 09/07/2015 at 17:33, xxxxxxxx wrote:

                      Hi Yannick,

                      When you are loading the fbx file,have you check the take start time and end time? If not, did it load very slow and have over millions of keyframes in the timeline?

                      Thanks,
                      Ben

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

                        On 13/07/2015 at 02:44, xxxxxxxx wrote:

                        Hi Ben,

                        Originally posted by xxxxxxxx

                        When you are loading the fbx file,have you check the take start time and end time? If not, did it load very slow and have over millions of keyframes in the timeline?

                        I tried with the GUI and the script.
                        When I load the file with the Merge dialog and check the take start and end times it loads quickly.
                        When I run the script it loads exactly as fast but without showing the take dialog and having to check the start and end times!

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