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
    • Login
    1. Home
    2. Firefly2021
    3. Posts
    F
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by Firefly2021

    • RE: OpenUSD (pxr) library in c4d python

      Hi llealloo,
      I installed usd-core at C4D R26 by powershell in this folder \Maxon Cinema 4D R26\resource\modules\python\libs\python39.win64.framework, and the following test code works fine and can produce the output usd file.
      Hope it may give you more clue.

      import c4d
      import pxr
      # following code from GTC_usd_introduction.ipynb------------------------------
      from pxr import Usd, UsdGeom
      # Create a tempory stage in memory
      stage = Usd.Stage.CreateInMemory('SampleLayer.usda')
      
      # Create a transform and add a sphere as mesh data
      xformPrim = UsdGeom.Xform.Define(stage, '/MySphere')
      
      # Set a translation
      UsdGeom.XformCommonAPI(xformPrim).SetTranslate((7,8,9))
      
      spherePrim = UsdGeom.Sphere.Define(stage, '/MySphere/MeshData')
      
      # Get the sphere as a generic prim
      sphere = stage.GetPrimAtPath('/MySphere/MeshData')
      
      # Get the extent and radius parameters for the prim
      radiusAttr = sphere.GetAttribute('radius')
      extentAttr = sphere.GetAttribute('extent')
      
      # Access the sphere schema to set the color
      colorAttr = spherePrim.GetDisplayColorAttr()
      
      # Set the radius to 2
      radiusAttr.Set(2)
      
      # Expand the extents to match the new radius 
      extentAttr.Set(extentAttr.Get()*2)
      
      # Make the sphere blue
      colorAttr.Set([(0,0,1)])
      
      # Print out the stage
      print(stage.GetRootLayer().ExportToString())
      
      # Save the resulting layer
      stage.GetRootLayer().Export('SampleLayer.usda')
      
      posted in Cinema 4D SDK
      F
      Firefly2021