Navigation

    • Register
    • Login
    • Search
    1. Home
    2. Jvos
    J

    Jvos

    @Jvos

    1
    Reputation
    8
    Posts
    122
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    Jvos Follow

    Best posts made by Jvos

    RE: string format

    @mikeudin seems to work. maybe because it needs to have c4d.REDSHIFT_LIGHT_PHYSICAL_EXPOSURE as an expression and not as a string.

    thanks a lot man!

    posted in Cinema 4D SDK •

    Latest posts made by Jvos

    RE: string format

    @mikeudin seems to work. maybe because it needs to have c4d.REDSHIFT_LIGHT_PHYSICAL_EXPOSURE as an expression and not as a string.

    thanks a lot man!

    posted in Cinema 4D SDK •
    string format

    how come that my string formatting is not working in C4D.

    exposure = lamp[c4d.REDSHIFT_LIGHT_PHYSICAL_EXPOSURE]
    

    this works like it should and give's me the exposure

    x = 'REDSHIFT_LIGHT_PHYSICAL_EXPOSURE'
    exposure = lamp[c4d.'{}'.format(x)]
    

    but this give's an invalid syntax.

    I want to format because I need a dict comprehension where I get each attribute from a list. like this

    attributes = ['REDSHIFT_LIGHT_PHYSICAL_INTENSITY', 'REDSHIFT_LIGHT_PHYSICAL_EXPOSURE']
    lamps = doc.GetActiveObjects(0)
    dict_variable = [{attr: lamp[c4d.'{}'.format(attr)] for attr in attributes} for lamp in lamps]
    

    is there maybe like a C4D slack? got always question, but also quick answers for other people. a forum is sometimes a bit slow.
    My thanks!

    posted in Cinema 4D SDK •
    RE: get lamp attributes?

    @mp5gosu
    Thanks for the example. but I still don't get the syntax right 😕
    any introduction maybe to read on? this seems super basic...
    If I drag in a parameter from a cube, let's keep using X.

    cube = doc.GetActiveObjects(0)
     x = cube[c4d.PRIM_CUBE_LEN,c4d.VECTOR_X]
    
    

    returns nothing. ('of course' probably) and the selected cube will not take GetParameter since it's a baseobjects and not a C4D.Atom class.
    but x = c4d.C4DAtom() is not allowed to be instantiated 😞

    edit:
    got it working. forum got's loads of answered question wich gave good insight. thanks

    posted in Cinema 4D SDK •
    RE: get lamp attributes?

    Hello mp5,

    Thanks for the info, I assumed only Python was available.
    Edited the question and marked it 👍

    posted in Cinema 4D SDK •
    get lamp attributes?

    I would like to call and get the attributes returned for a redshiftlamp.
    In Maya it is close to this.
    selectedobject.getattr('intensity')
    which will return me 5

    How would I approach this in Python for Cinema, I need to do this for almost all the attributes.

    My thanks!

    posted in Cinema 4D SDK •
    RE: ReferenceError?

    @cairyn
    ah yeah, that was a dumb mistake. Got it working now. thanks you for that., but I do still have a question.
    If I want to inherit from c4d modules in my own class as a child. how would I do that? I tried it like this.

    from c4d.modules.thinkingparticles.TP_MasterSystem import TP_MasterSystem
    
    class Particle(TP_MasterSystem):
    

    but that is not how it works. 😕

    The import seems to work fine. but I'm not able to inherit the particle class methods like size or life.
    type 'c4d.modules.thinkingparticles.TP_MasterSystem' is not an acceptable base type

    posted in Cinema 4D SDK •
    RE: ReferenceError?

    thanks for the response, make's everything a bit more clear now.
    I got the numpy module in C4D. so if I want to generate multiple objects with a generator and not place the objects directly into C4D, I expected something like this quick example to work.

    import c4d
    
    def main():
        y = 0 
        for i in range(10):
            vec = c4d.Vector(y,230,y)
            obj = c4d.BaseObject(c4d.Ocube)  # Create new cube
            obj.SetRelPos(c4d.Vector(vec))  # Set position of cube
            y += 100
            return obj
    main()
    

    why would a generator only give me 1 and not 10 cubes cloned?
    chancing the return line and adding them directly into the document works, and gives me 10 cubes.
    doc.InsertObject(obj)

    my thanks

    posted in Cinema 4D SDK •
    ReferenceError?

    Got a simple script that gives me errors.
    First time in C4D so maybe it is a simple API call mistake, but it does not seem so.
    the error isReferenceError: could not find 'main' in generator 'Python Generator'

    My thanks for helping out, looking forward to building cool stuff in C4D

    import numpy as np
    
    n = 10
    y = 0
    grid = np.random.choice([1, 0], n * n).reshape(10, 10)
    for i in range(n):
        for j in range(n):
            if grid[i, j] == 1:
                vec = c4d.Vector(i * 230, j * 230, y)
                obj = c4d.BaseObject(c4d.Ocube)  # Create new cube
                obj.SetRelPos(c4d.Vector(vec))  # Set position of cube
                doc.InsertObject(obj)  # Insert object in document
    
    posted in Cinema 4D SDK •