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
    • Register
    • Register
    • Login
    1. Maxon Developers Forum
    2. jcooper
    3. Topics
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 13
    • Best 2
    • Controversial 0
    • Groups 0

    Topics created by jcooper

    • jcooperJ

      R24.111: shiboken2 fails to load (Win10)

      General Talk
      • python s24 • • jcooper
      3
      1
      Votes
      3
      Posts
      840
      Views

      ferdinandF

      Hello @jcooper,

      thank you for reaching out to us. First of all, I must point out that what you are trying to do is out of scope of support. We cannot support third party libraries as stated in our Forum Guidelines and we especially cannot support third party GUIs.

      The little help I can give you here is to say:

      There is currently a bug in R25 which will cause faulty installations when using pip and having a vanilla CPython installation of the same version on the system. The installation itself will work fine, but the import paths of both Pythons will become entangled in this case due CPython having some hardcoded import paths in its code pointing to the user directories. We have fixed this problem and the fix will be delivered with an upcoming release. You can check this easily by checking the installation paths of modules with the ```fileattribute of the module. When you are encountering the problem, it will be pointing towards yourCPython`` site-packages and not the
      one from Cinema. There is not much what you can do to fix this yourself (aside from monkey-patching our Python yourself). There is more than sys.path in Python, there is also sys.meta_path and relative imports, so just being able to import other packages in the same path is no guarantee that everything is fine.

      I cannot say much more with the given little information, and we can unfortunately also not support third party libraries. You should check if indeed is everything installed in the correct location. The problem you have could be related to what I describe under 1., but that bug did exist for quite some time, so it should have failed before.

      Cheers,
      Ferdinand

    • jcooperJ

      Setting XRef options via python?

      Cinema 4D SDK
      • • • jcooper
      6
      0
      Votes
      6
      Posts
      1.0k
      Views

      P

      @ferdinand ok I will open another thread for this 🙂

    • jcooperJ

      Materials don't accept Tags?

      Cinema 4D SDK
      • r21 python • • jcooper
      4
      0
      Votes
      4
      Posts
      701
      Views

      ManuelM

      hi,

      without futher feedback from you i'll set this thread to solved.

      Cheers,
      Manuel

    • jcooperJ

      Making Houdini Engine visible to C4D via Python

      Cinema 4D SDK
      • r21 python • • jcooper
      4
      0
      Votes
      4
      Posts
      857
      Views

      jcooperJ

      @r_gigante Perfect! Worked like a charm. Thank you.

    • jcooperJ

      How do I access Redshift AOV settings from Python?

      Cinema 4D SDK
      • • • jcooper
      3
      0
      Votes
      3
      Posts
      1.6k
      Views

      lasselauchL

      Wow, thanks for the example, @r_gigante.

      Was it always possible to import a redshift module? Or is there any info from which version on (C4D / Redshift) this is possible!?

      Thanks,
      Lasse

    • jcooperJ

      Alembic camera properties

      Cinema 4D SDK
      • python r21 • • jcooper
      2
      0
      Votes
      2
      Posts
      485
      Views

      ManuelM

      Hello,

      Some symbols are not exposed to public. There's no particular reason for that.
      There's no real place where all exposed symbols are. (and we agree it's could be nice)

      To know if a BaseObject is a camera (or something) you can use IsInstanceOf

      You can also send a message using the ID MSG_GETREALCAMERADATA :

      with an alembic generator you can use this code :

      camera = doc.GetActiveObject() if camera is None: return if camera.IsInstanceOf(c4d.Oalembicgenerator) == False: return # This example tries to get the internal camera from a generator. # Typically used with the Alembic Generator camera. data = {} data["res"] = None res = camera.Message(c4d.MSG_GETREALCAMERADATA, data) if res: camera = data["res"] print("Camera: " + camera.GetName())

      For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

      Q&A New Functionality. How to Post Questions especially the tagging part.

      I've marked this thread as a question so when you considered it as solved, please change the state 🙂

      Cheers,
      Manuel

    • jcooperJ

      Menu items without RegisterCommandPlugin?

      Cinema 4D SDK
      • • • jcooper
      11
      0
      Votes
      11
      Posts
      1.8k
      Views

      M

      Hi, I'm sorry for the delay, but I can only confirm what you said.
      In C++ it's possible to call RegisterCommandPlugin but not in Python at runtime.

      So I guess the best approach is to have as you suggested a menu entry (a pre-registered c4d script or CommandData) that will then create a PopuDialog with a list of all scripts, and then it's up to you to execute them with the code @lasselauch provided.
      So here an example of how to implement it.

      import c4d import os def main(): # Gets all python script of a folder searchPath = r"%appdata%\Roaming\Maxon\Maxon Cinema 4D R21_115_XXXXXX\library\scripts" pythonFiles = [os.path.join(folder, f) for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f)) and f.endswith(".py")] # Build the menu for all the entries menu = c4d.BaseContainer() for pythonFileId, pythonFile in enumerate(pythonFiles): menuId = c4d.FIRST_POPUP_ID + pythonFileId filename = os.path.basename(pythonFile) menu.InsData(menuId, filename) # Example to also list regular command. # Uses POPUP_EXECUTECOMMANDS in ShowPopupDialog flag so if its a command its executed directly menu.InsData(c4d.Ocube, "CMD") # Display the PopupDialog result = c4d.gui.ShowPopupDialog(cd=None, bc=menu, x=c4d.MOUSEPOS, y=c4d.MOUSEPOS, flags=c4d.POPUP_EXECUTECOMMANDS | c4d.POPUP_BELOW | c4d.POPUP_CENTERHORIZ) # If result is bigger than FIRST_POPUP_ID it means user selected something if result >= c4d.FIRST_POPUP_ID: # Retrieves the selected python file scriptId = result - c4d.FIRST_POPUP_ID pythonFile = pythonFiles[scriptId] # Execute it and copy the global to it ( so doc, op are accessible as well) fl = open(pythonFile, 'rb') code = compile(fl.read(), pythonFile, 'exec') exec(code, globals()) # Execute main() if __name__=='__main__': main() ``` Cheers, Maxime.
    • jcooperJ

      How to set completely custom render output filename?

      Cinema 4D SDK
      • python • • jcooper
      6
      0
      Votes
      6
      Posts
      1.7k
      Views

      r_giganteR

      @jcooper said in How to set completely custom render output filename?:

      How do I control how much zero-padding is used for the $frame token? We typically use 4-digit, zero-padded frame tokens, but what if a situation called for, say, 6 digits?

      Hi John, with regard to the $frametoken the zero-padding is hardcoded but as stated by @zipit you can workaround it by registering your token (see here)
      .

      How do I get at the RenderData for a specific renderer such as Redshift? For instance, it has its own "filename" attribute, but I don't know how to access/modify it from the python API.

      You need to retrieve the RedShift BaseVideoPost and retrieve the corresponding data from its BaseContainer.

      Check the code below

      # Get the active RenderData renderData = doc.GetActiveRenderData() if renderData is None: raise RuntimeError("Failed to retrieve the render data.") # Get the active render settings renderSettings = renderData.GetData() if renderSettings is None: raise RuntimeError("Failed to retrieve the render settings.") # Get the first video post videopost = renderData.GetFirstVideoPost() if videopost is None: raise RuntimeError("Failed to retrieve the videopost associated with the render data.") # Search for the RedShift videopost while videopost is not None and videopost.GetType() != 1036219: print "RedShift is not set as renderer in the active RenderData, check next" videopost = videopost.GetNext() rsAOV = None # Retrieve the AOV -> Filname param value if videopost is not None and videopost.GetType() == 1036219: rsAOV = videopost[c4d.REDSHIFT_RENDERER_AOV_PATH] # Reads the path stored in the render setting path = renderSettings[c4d.RDATA_PATH] # Add token to the path path = path + rsAOV # Tokenizes the path from the render engine rpd = {'_doc': doc, '_rData': renderData, '_rBc': renderSettings, '_frame': 1} exclude = [] finalFilename = c4d.modules.tokensystem.FilenameConvertTokensFilter(path, rpd, exclude)+".png" print finalFilename