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
    1. Maxon Developers Forum
    2. owen
    3. Topics
    O
    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 8
    • Best 0
    • Controversial 0
    • Groups 0

    Topics created by owen

    • O

      Merge IsolateObjects into a second document

      Cinema 4D SDK
      • r20 python windows • • owen
      2
      0
      Votes
      2
      Posts
      499
      Views

      ManuelM

      hi,

      you have to save the document to memory and use the result to merge the document.
      When you merge, you have to set the flags to what you want to merge, otherwise it will not merge what you want.

      On this example i'm merging a document with another selected document.

      import c4d from c4d import gui # Welcome to the world of Python # Main function def main(): obj = doc.GetActiveObject() if obj is None: return # Isolate the active object isolateDoc = c4d.documents.IsolateObjects(doc, [obj]) # Creates the Memory File Strcuture mfs = c4d.storage.MemoryFileStruct() # Sets the mfs to write mode mfs.SetMemoryWriteMode() # save the document to mfs c4d.documents.SaveDocument(isolateDoc, mfs, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_C4DEXPORT) # retrieve the data data = mfs.GetData() # Set the MFS to read mode mfs.SetMemoryReadMode(data[0], data[1] ) flags = c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS # Load Document selectedFile = c4d.storage.LoadDialog() if selectedFile is None: return newDoc = c4d.documents.LoadDocument(selectedFile, flags) #Merge the isolated document with the current one. c4d.documents.MergeDocument(newDoc, mfs, flags) c4d.documents.InsertBaseDocument(newDoc) c4d.documents.SetActiveDocument(newDoc) # Execute main() if __name__=='__main__': main()

      Cheers,
      Manuel

    • O

      How to work with LoadFile from content browser

      Cinema 4D SDK
      • python windows r20 • • owen
      4
      0
      Votes
      4
      Posts
      655
      Views

      ManuelM

      hi,

      you could also use LoadDocument

      lowPoly = c4d.documents.LoadDocument("preset://Optimized_Assets.lib4d/Asset_Library.c4d", c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS)

      As the documentation says:
      Similar to LoadFile() but this time the document is not put into the editors list of documents and it gives control over the loaded document.

      Cheers,
      Manuel

    • O

      MatrixToHPB Negative values

      Cinema 4D SDK
      • python r20 • • owen
      4
      0
      Votes
      4
      Posts
      992
      Views

      r_giganteR

      Hi @owen, thanks for following up.

      As @m_adam has already pointed out there's actually no difference in the values defininig a matrix representing a rotation on -30, -390, 330 or 690 on a certain axis.
      The lifesafer in this case is to use the already mentioned GetOptimalAngle which actually provides you with the HPB vector that would minimize the rotation given the previous HPB and the current HPB.

      For the sake of completeness let's assume that at frame 0 H = 0 whilst at frame 1 H = -5.

      Running the following code just returns the "expected" HPB vector

      def main(): # set the lastHPB to the previous frame value (in this case zero) lastHPB = c4d.Vector(0,0,0) # retrieve the current rotation order rotOrder = op.GetRotationOrder() # convert from matrix to HPB representation currentHPB = c4d.utils.MatrixToHPB(op.GetMg(), rotOrder) # get the optimal HPB vector optimalHPB = c4d.utils.GetOptimalAngle(lastHPB, currentHPB, rotOrder) print optimalHPB

      Now using this strategy and knowing the HPB of a clone at the previous frame, you are able to obtain a meaningful HPB representing of the matrix describing the rotation at the current frame of a certain clone (or object).

      Best, Riccardo

    • O

      SetPixel() for 32 bit float images

      Cinema 4D SDK
      • python r20 sdk • • owen
      3
      0
      Votes
      3
      Posts
      845
      Views

      O

      Thanks so much this is exactly what I was looking for.

    • O

      Checking Keyframe curve type

      Cinema 4D SDK
      • python r19 windows sdk • • owen
      2
      0
      Votes
      2
      Posts
      637
      Views

      S

      Hello and welcome,

      what exactly do you mean with "export keyframe data"? Do you want to write data into a file? The best way to develop such code would be in a Python script that you can edit and execute in the Script Manager. A XPresso Python node is meant to contain code that is executed as part of XPresso to define the behavior of the XPresso network. A XPresso Python node should not be used to modify the scene or to perform I/O operations.

      A CTrack object stores the DescID of the associated parameter. You can access that DescID with GetDescriptionID().

      Alternatively you can use BaseList2D.FindCTrack() to search for the CTrack associated with a certain parameter DescID. You find an example on GitHub.

      You find general information on how to use CTrack and DescID also in the C++ documentation:

      CTrack Manual DescID Manual

      best wishes,
      Sebastian