Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Browsing Plugin Paths

    Cinema 4D SDK
    c++ sdk r20
    3
    4
    1.5k
    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.
    • D
      d_schmidt
      last edited by

      Hello, I'm looking for a way to get the filepaths from the Preferences -> Plugins -> Search Paths menu. I have a circumstance where one plugin needs to know where another plugin is installed so I want to be able to check those remote paths, but I can't figure out how to access the parameter.
      alt text

      GetWorldContainer() doesn't seem to contain this parameter but it does others, so I'm not sure where to go from here.

      Dan

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        preference data is often even for native c4d features implemented as a PreferenceData plugin. You have to access that plugin then. To get there you can drag and drop description elements into the python command line, delete the __getitem__() part (the stuff in brackets), and get the __repr__ of the object. With that you can figure out the plugin ID of the corresponding BasePlugin and then access your values.

        For your case as a script example:

        import c4d
        from c4d import plugins
        # Welcome to the world of Python
        
        def main():
            # Search for a plugin ID with a known str __repr__ of a BasePlugin. We got from the console:
            # Drag and drop: Plugins[c4d.PREF_PLUGINS_PATHS]
            # >>> Plugins
            #     <c4d.BaseList2D object called 'Plugins/Plugins' with ID 35 at 0x0000028FE8157A50>
            pid, op = None, plugins.GetFirstPlugin()
            while op:
                if 'Plugins/Plugins' in str(op):
                    pid = op.GetID()
                    break
                op = op.GetNext()
            print "pid:", pid
            
            # Use that ID
            op = plugins.FindPlugin(pid)
            if op:
                print op[c4d.PREF_PLUGINS_PATHS] # we know the enum from the console
        
        # Execute main()
        if __name__=='__main__':
            main()
        

        You can use then that Plugin ID in cpp to do the last part (Use that ID) there.

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 2
        • ManuelM
          Manuel
          last edited by Manuel

          hello,

          thanks @zipit for the answer.

          @d_schmidt, please, don't forget to mark your thread as a question and mark it as solved once it is. That help us 🙂

          Instead of getting the preferences, you can use GetModulePaths. It returns all module paths configured through g_modulePath, g_additionalModulePath and user preferences. Including Corelibs and Plugins default directories.

          You can have information on Application manual

                  // Returns all module paths configured through g_modulePath, g_additionalModulePath and user preferences.
          	// include corelibs and plugins default directory.
          
          	const maxon::BaseArray<maxon::Url> myPluginPaths = maxon::Application::GetModulePaths() iferr_return;
          	
          	for (auto plugPath : myPluginPaths)
          		DiagnosticOutput("plugins path @", plugPath);
          
          

          If you do know the plugin ID, you can also use this kind of code.

                  const maxon::Int32 plugin_ID = 1038235;
          
          	BasePlugin* myPlugin = FindPlugin(plugin_ID, PLUGINTYPE::ANY);
          
          	if (myPlugin == nullptr)
          		return maxon::NullptrError(MAXON_SOURCE_LOCATION);
          
          	const Filename myPluginPath = myPlugin->GetFilename();
          	const maxon::String directory = myPluginPath.GetDirectory().GetString();
          
          	DiagnosticOutput("directory of plugin @ is @", plugin_ID, directory);
          

          Cheers
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 2
          • D
            d_schmidt
            last edited by

            Thank you both for the replies! Between both of them I have exactly what I need, thanks.

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