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
    • Register
    • Login

    How to draw svg to bitmaps?

    Scheduled Pinned Locked Moved Cinema 4D SDK
    windowspython2026
    2 Posts 2 Posters 24 Views 2 Watching
    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.
    • DunhouD Offline
      Dunhou
      last edited by

      Hey community,

      I want to display capsule assets with icon with maxon.AssetUtilitiesInterface.GetAssetIcon , but some of the icon is in svg format, can we draw this into a bitmap like command palate did?

      import c4d
      import maxon
      
      doc: c4d.documents.BaseDocument  # The currently active document.
      op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
      
      def main() -> None:
          """Called by Cinema 4D when the script is being executed.
          """
          repo = maxon.AssetInterface.GetUserPrefsRepository()
          uid = maxon.Id("file_bc73b379cb5e509e")
          # this is the ivy capsule id, it has a svg icon
          # uid = maxon.Id("com.rocketlasso.neutron.asset.generator.ivy")
      
          asset_description = repo.FindLatestAsset(
              maxon.AssetTypes.File(), uid, maxon.Id(), maxon.ASSET_FIND_MODE.LATEST)
          preview_url = maxon.AssetUtilitiesInterface.GetAssetIcon(asset_description)
          bmp = c4d.bitmaps.BaseBitmap()
          result, _ = bmp.InitWith(preview_url)
          if result != c4d.IMAGERESULT_OK:
              return None
          c4d.bitmaps.ShowBitmap(bmp)
      
      if __name__ == '__main__':
          main()
      

      Cheers~
      DunHou

      https://boghma.com
      https://github.com/DunHouGo

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

        Hello @Dunhou,

        Thank you for reaching out to us. I am afraid that this is not possible within our Python API at the moment.

        Internally, BaseBitmap is what we call an adapter. It is a hollowed out type from older days, which only continues to exist so that we do not have to rewrite large parts of our code base. A BaseBitmap wraps internally an ImageInterface, where also the sub-type VectorImageInterface exists. Unfortunately, neither of these Maxon API interfaces are exposed to Python, and it is also somewhat unlikely that they will be in the future. The reason why your code bmp.InitWith(preview_url) does not work, is because the backend function ::InitFromFile which implements BaseBitmap::InitWith operates based on bitmap loaders and VectorImageInterface is not a bitmap loader, because it was implemented long after the 'classic' Cinema API.

        When I have some time, I will try to monkey patch a BaseBitmap.FromVectorImage method into the Python API. For now, you would have to use an external library such as Pillow.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

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