Navigation

    • Register
    • Login
    • Search
    1. Home
    2. owen
    3. Posts
    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by owen

    Merge IsolateObjects into a second document

    I have a list of objects in one document (OptimizedDoc) that I want to copy over into another (doc) with materials and tags. My current code is:

    tempDoc = c4d.documents.IsolateObjects(OptimizedDoc, Transfer_Objects)
    c4d.documents.MergeDocument(doc, tempDoc, c4d.SCENEFILTER_NONE)
    

    I get - TypeError: unable to convert c4d.documents.BaseDocument to @net.maxon.interface.url-C
    The documentation says the second spot on Merge Document should be the file to merge into doc, but I think the way I'm presenting it is incorrect. Am I supposed to be pointing to a file location in memory? Thanks!

    posted in Cinema 4D SDK •
    RE: How to work with LoadFile from content browser

    @Cairyn Perfect, that did the trick, thanks!

    posted in Cinema 4D SDK •
    How to work with LoadFile from content browser

    My goal is to quickly replace high poly models with low poly versions. The high poly models are being pulled from a library by architects, so the names are complex and always the same. I have started building a document in Cinema with low poly versions of these with correct UV and textures that I saved to the content browser. My thinking is that when I import their model, I run a script that
    1 - Creates a list of all the active objects in the current scene
    2 - Opens the document that holds the low poly versions
    3 - Copy any objects in the low poly document that match the list of objects from the architect's model
    4 - Paste those objects in to the document that has the architect's model
    5 - Replace the high poly models with the low poly version

    The part I'm stuck on is opening and then working with the document from the content library. This is my code so far:

    def main():
    
        #Make list of selection
        Object_List = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
    
        #Open low poly library file from content browser
        c4d.documents.LoadFile("preset://Optimized_Assets.lib4d/Asset_Library.c4d")
    
        #This is where I would compare the objects in the scene to the Object_List
        print c4d.documents.BaseDocument.GetObjects(doc)
    

    The console prints out a list of objects in the architects model, so I'm wondering why that stays as doc and not the file that was just loaded and how to switch between the files I want to work with in python?

    posted in Cinema 4D SDK •
    RE: MatrixToHPB Negative values

    Thanks @m_adam and happy new year!

    I should explain some of the use case for this. I have a large array of clones that have some set parameters they must stay in (a cube can have a rotation value between -500 degrees and +1200 degrees and so on). When I'm trying to get the rotation values from the cloned objects the only thing I'm seeing in the SDK is the MatrixToHPB; but like you said because -270 is essentially the same position as +90 both values in the matrix are identical. Do you know if there is a way to get the value in a similar way that .GetAbsRot() works for single objects?

    posted in Cinema 4D SDK •
    MatrixToHPB Negative values

    Hello, I'm trying to get the rotation values of clones but having some trouble with negative rotations. It looks like the code is working as expected for positive values, but if a clone is rotated to a negative value, the MatrixToHPB spits out a positive value.

    import c4d
    from c4d.modules import mograph as mo
    
    def main():
        #Starting object has a rotation value of H = -30 degrees
        Export_Manager = doc.SearchObject("Export_Manager")
        Obj_1 = Export_Manager[c4d.ID_USERDATA, 9]
        MoData = mo.GeGetMoData(Obj_1)
        marr = MoData.GetArray(c4d.MODATA_MATRIX)
        #Matrix is showing negative values  Matrix(v1: (0.866, 0, -0.5); v2: (0, 1, 0); v3: (0.5, 0, 0.866); off: (0, 0, 0))
        print marr[0]
        #Conversion shows positive values   Vector(5.76, 0, 0)
        print c4d.utils.MatrixToHPB(marr[0])
    
    if __name__=='__main__':
        main()
    

    Thanks!

    posted in Cinema 4D SDK •
    RE: SetPixel() for 32 bit float images

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

    posted in Cinema 4D SDK •
    SetPixel() for 32 bit float images

    In the class c4d.bitmaps.BaseBitmap you can call BaseBitmap.SetPixel() to set the color value of an individual pixel. It seems like it only takes in values between 0 and 255 for RGB. I'm working with MultipassBitmap to create a 32 bit float image and want to be able to modify the individual pixels. Is there a similar way to change the pixel values so I could feed it a value between 0 and 1?

    posted in Cinema 4D SDK •
    Checking Keyframe curve type

    I'm creating a python script to export keyframe data. When doing this I want to check to make sure that the keyframes are on either a position or a rotation track and ignore all others. I'm a little lost on how to do that check. I'm currently building this in xpresso with a python node and hoping to later convert it to a plug in. Here is my current code with comments.

    import c4d
    import math
    
    def main():
        # Get a list of all the animation tracks for the object
        track = Object.GetCTracks()
        #iterate through the list of tracks
        for x in track:
            #---Here I would like to check if this is rotation/position track or something that should be ignored ----
            print x
            #---- When x is printed I receive <c4d.CTrack object called 'Position . Y/Track' with ID 5350 at 0x0000025FC3AE2770> so I can see its position but I don't know how to sort that out -----
    

    I think what I'm looking for is a GetTrackName or something along those lines?

    Edit a_block: Added code tags

    posted in Cinema 4D SDK •