Navigation

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

    Posts made by mocoloco

    RE: Keyframing the source file on an ImageTexture shader

    Hi,

    A simple addition on CTrack and DescId as I was also faced to this a time ago. You can consult the @ferdinand's explanations and exemples on CTrack to the following post :

    https://plugincafe.maxon.net/topic/14315/solved-how-to-setup-a-ctrack-on-tag-plugin-ui-slider-with-extended-details/8

    Cheers,
    Christophe

    posted in Cinema 4D SDK •
    RE: Struggling on SetParameter for OLight

    Hi @m_adam,

    Thanks a lot for the flags, it does work as expected now.
    Are c4d.DESCFLAGS_GET_NONE and c4d.DESCFLAGS_GET_0 similars?

    Cheers,
    Christophe.

    posted in Cinema 4D SDK •
    RE: Struggling on SetParameter for OLight

    Little addition after looking for a solution and reading more on OLight, it seems that the correct data type is c4d.DTYPE_VECTOR instead of c4d.DTYPE.COLOR. But even with this I can't reach the value.

     # TAG Execute() method
    def Execute(self, tag, doc, op, bt, priority, flags):
        self.tagData = tag.GetDataInstance()
        sim_color = c4d.Vector(0) # For debug purpose, set a black color value
    
        if op.GetType() == c4d.Olight:
            # For debug purpose  
            print( op.GetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_VECTOR, 0)), c4d.DESCFLAGS_GET_PARAM_GET ) )
    
            op.SetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_VECTOR, 0)), sim_color, c4d.DESCFLAGS_SET_USERINTERACTION )
        
            return c4d.EXECUTIONRESULT_OK
    
    posted in Cinema 4D SDK •
    Struggling on SetParameter for OLight

    Hello there!

    I'm starting a new TAG plugin development and I would like to affect OLight parameter, i.e. c4d.LIGHT_COLOR, but my DescId does not reach its target.

    All this is happening in dataTag.Execute.

    Here the code, and the GetParameter returns only None, which means there is something wrong...

     # TAG Execute() method
    def Execute(self, tag, doc, op, bt, priority, flags):
        self.tagData = tag.GetDataInstance()
        sim_color = c4d.Vector(0) # For debug purpose, set a black color value
    
        if op.GetType() == c4d.Olight:
            # For debug purpose  
            print( op.GetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_COLOR, 0)), c4d.DESCFLAGS_GET_PARAM_GET ) )
    
            op.SetParameter( c4d.DescID(c4d.DescLevel(c4d.LIGHT_COLOR, c4d.DTYPE_COLOR, 0)), sim_color, c4d.DESCFLAGS_SET_USERINTERACTION )
        
            return c4d.EXECUTIONRESULT_OK
    

    I tried different flags for SetParameter, but based on @ferdinand explanation on CTrack, it seems that c4d.DESCFLAGS_SET_USERINTERACTION is the good one.

    If someone can light me up on this, that would be awesome.

    Cheers,
    Christophe

    posted in Cinema 4D SDK •
    RE: Back on "message after tag delete" post

    Hi @ferdinand,

    Thanks a lot one more time for all the detailed examples and informations.

    I finally opt to a data container of the node, mostly due to the fact that the hooks are volatile and need to be set all the time. I also ran some tests with globals without having encounter issues, but indeed you need to be careful when handling this approach.

    Cheers,
    Christophe

    posted in Cinema 4D SDK •
    RE: Back on "message after tag delete" post

    Hello @ferdinand,

    First of all many thanks for giving a such precise and well documented answers to issues I'm facing, that is tremendous.

    Then, you confirmed what I noticed and thought about the redundancy of calling/freeing; and like you said maybe I have to approach the problem differently.

    The current plugin I'm working on is use in a really specific case, that way, maybe the approach with the events notification can work. I have to test that based on what you wrote.
    I was asking this because I want to reset some globals var when the TAG is removed - maybe there is a more elegant way to do, but until now I haven't found one yet.

    Have a good day!
    Cheers,

    Christophe

    posted in Cinema 4D SDK •
    Back on "message after tag delete" post

    Hi there,

    I'm looking for a reliable method to know when a TAG is deleted. I was hoping that a destructor exists somehow, it it does not work as expected. I tried __del__(self) as well as NodeData.Free(self, node) in my class. Both are called on TAG deletion, but they are also called on any user interaction, which looks really weird.

    I went through old post, https://plugincafe.maxon.net/topic/7838/10131_message-after-tag-delete?_=1674474478232, which state exactly the same result without any solution.

    Is there a way to know when a TAG has been deleted or destroyed from an object without having to watch constantly the whole hierarchy?

    Thanks a lot,
    Cheers,

    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    Oh, I didn't know about the to fix tag. Keeping unsolved was much more for the community 😉
    I the meantime I setup the resource file as discussed, and indeed, having higher values prior setting them solve the GUI problem / which is a good fix for me.

    Thanks a lot,
    Cheers,

    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    Good morning @ferdinand,

    Thanks a lot for taking time going though this. That's exactly what I noticed last week. Changed are took into account but they are not reflected on the GUI. The only workaround that seems possible at this moment is to set MIN/MAX sliders values beyond the possible values that could be set on UserData. Doing so GUI should behave correctly.

    Could you please let this thread unsolved for the moment, the time we get a fix on this?

    Have a great day,
    Cheers,

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    Hi @ferdinand,

    I was quite sure indeed that UNIT PERCENT will work, but I give a try to see. What I do not understand is, when I'm printing all the values existing in desc_X or desc_Y, they looks good, the value is correct, but not took completely into account on the drawing side for CUSTOMGUI REALSLIDER.

    Like I said, if I remove the CUSTOMGUI REALSLIDER; option in the resource file and using REAL as a standard input field, whatever the UNIT I'm using, everything behaves correctly. MIN/MAX values are correctly assigned even though there is multiple REAL that need to be change. That let me lead like you to a bug linked to CUSTOMGUI REALSLIDER when only using UNIT DEGREE.

    No problem to have a look on this next week. I can deal with that for the moment using PERCENT, as is produce slightly the same result. It is just not really convenient to guess a percentage for an angle, but that's OK.

    Many thanks,
    Cheers,

    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    Hi @ferdinand,

    Thanks a lot for your time on this and sorry for the wrong unit on the first example I submitted with METERS instead of DEGREES - at the sometime it seems that it raised some kind of bug link to this ^^.

    Like you wrote, I did convert the value in Radian for all the Parameters and so, but anyway the problem seems linked to the simultaneous use of UNIT DEGREES; CUSTOMGUI REALSLIDER in the resource file.

    I ran a couple of tests and I noticed the following:
    • When only using REAL without CUSTOMGUI REALSLIDER; in the resource file, the field behaves as it should and limits changes works as expected
    • When using CUSTOMGUI REALSLIDER; with UNIT METERS; it does work as well as expected
    • When using UNIT PERCENT; with MIN -100.0; MAX 100.0 and assigning the values by multiplying the slider value by Parameters[--max], printing and assigning the result to a STATICTEXTit displays the right value in degree or rad depending on the final conversion made prior display.
    • When assigning UNIT DEGREES; with CUSTOMGUI REALSLIDER, I'm getting weird behaviour like said previously and like you noticed.

    I haven't had the time to ran test today with INTERFACE_DATA like you suggested. I will try to do that tomorrow and I will keep you in touch about this.

    Cheers,
    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    You can add the following code to see the values before and after new assignment. You will see that the values are correctly changed, but the change does not reach the interface for unknown reason.

    for k,v in desc_Y:
        print(f"Y New, Key {k} / Val {v}")
    
    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    @ferdinand,

    There is something weird going on. I intend to change several sliders accordingly to Parameters, ID_X and ID_Y.
    I adapted the code accordingly, but it seems that only DESC_MAXSLIDER and DESC_MINSLIDER are took into account while DESC_MIN and DESC_MAX stick to previous values. Could that be a bug?

    Screenshot 2023-01-16 at 16.02.40.png

    I let in remarks the code that improve a bit better the result and allows ID_X to be fully set (MIN/MAX as well as MINSLIDER/MAXSLIDER), but the problems remains on ID_Y.

    Screenshot 2023-01-16 at 16.03.14.png

    Here the whole code of GetDDescription(),

    global Parameters
    Parameters = dict()
    Parameters['Xmin'] = -360.0
    Parameters['Xmax'] = 360.0
    Parameters['Ymin'] = -25.0
    Parameters['Ymax'] = 25.0
    
    def GetDDescription(self, node, description, flags):  
        if not description.LoadDescription(node.GetType()):
            return False  
    
        # Change Slider limits accordingly to Parameters values
        # Sliders to modifiy ID_X, ID_Y
    
    
        ## SLIDER ID_X
        if len(Parameters) > 0:
            paramID_X: c4d.DescID = c4d.DescID(c4d.DescLevel(ID_X, c4d.DTYPE_REAL, 0))
            single_X: c4d.DescID = description.GetSingleDescID()
            # Bail when there is a to be evaluated parameter and our parameter is not part off or equal to the to be evaluated parameter.
            if single_X and not paramID_X.IsPartOf(single_X):
                return True, flags
            # if singleId[0] == mAXIS_X: print (f"singleID found: {singleId} ")
            # Get the description data container instance (GetParameter>I<) for the parameter we want to modify
            desc_X: c4d.BaseContainer = description.GetParameterI(paramID_X)
            if desc_X is None:
                return True, flags
    
            # if single_X and paramID_X.IsPartOf(single_X):
            #     if paramID_A1.IsPartOf(single_X)[0]:
                    # Write the MAX and MAXSLIDER values based on UserDatas
            desc_X[c4d.DESC_MIN] = c4d.utils.DegToRad(Parameters["Xmin"])
            desc_X[c4d.DESC_MINSLIDER] = c4d.utils.DegToRad(Parameters["Xmin"])
            desc_X[c4d.DESC_MAX] = c4d.utils.DegToRad(Parameters["Xmax"])
            desc_X[c4d.DESC_MAXSLIDER] = c4d.utils.DegToRad(Parameters["Xmax"])
            # if single_X and paramID_X.IsPartOf(single_X):
            #     if paramID_X.IsPartOf(single_X)[0]:
            #         print (f"Found X: {paramID_X.IsPartOf(single_X)[0]} ")
            #         return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
                    
    
            ## SLIDER ID_Y
            paramID_Y: c4d.DescID = c4d.DescID(c4d.DescLevel(mAXIS_Y, c4d.DTYPE_REAL, 0))
            single_Y: c4d.DescID = description.GetSingleDescID()
            # Bail when there is a to be evaluated parameter and our parameter is not part off or equal to the to be evaluated parameter.
            if single_Y and not paramID_Y.IsPartOf(single_Y):
                return True, flags
            # Get the description data container instance (GetParameter>I<) for the parameter we want to modify
            desc_Y: c4d.BaseContainer = description.GetParameterI(paramID_Y)
            if desc_Y is None:
                return True, flags
            # Write the MAX and MAXSLIDER values based on UserDatas
            desc_Y[c4d.DESC_MIN] = c4d.utils.DegToRad(Parameters["Ymin"])
            desc_Y[c4d.DESC_MINSLIDER] = c4d.utils.DegToRad(Parameters["Ymin"])
            desc_Y[c4d.DESC_MAX] = c4d.utils.DegToRad(Parameters["Ymax"])
            desc_Y[c4d.DESC_MAXSLIDER] = c4d.utils.DegToRad(Parameters["Ymax"])
            # if single_Y and paramID_A2.IsPartOf(single_Y):    
            #     if paramID_Y.IsPartOf(single_Y)[0]:
            #         print (f"Found Y: {paramID_Y.IsPartOf(single_Y)[0]} ")
            #         return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
                
    
       return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
    

    Does this trick to change REALSLIDER MIN/MAX values intend to be associated to only on change, and not on several UI object?

    Thanks in advance,
    Cheers,

    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    @ferdinand,

    I found the problem. For a reason I can't explain, going through the new assignment once on the first call of GetDDescription() isn't enough. I thought that I could do the change once on first plugin TAG load/use, then avoid to going through this change each time GetDDescription() is called. But that's isn't the case. It seems that the change need to be perpetual and need to be parsed and evaluated constantly to be seen and changed in the interface ( honestly I found this weird and not really optimised in terms of coding ).

    So, by getting rid of the flag FIRST_INIT (which wasn't in the code above), the code does work as expected.

    Maybe could you explain me why this repetitive reassignment is needed?

    Thanks a lot for your prompt support and all detailed explanation you are providing, it does help a lot.
    Cheers,

    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    Hello @ferdinand,

    Thanks for your reply. To answer you to all your question in order,

    Yes, my code hit the statement print(f"min { Parameters['Xmin'] } / max {Parameters['Xmax']}" ) and I'm getting in console the following

    singleId = (1551, 0, 0)
    min -25.0 / max 25.0
    

    I was a bit afraid about what you confirmed me, that, .SetParameter() wouldn't change anything about writing the values. So there should be something else...

    I'm going to test this part of the code independently with this only assignment and see if it works or not.

    About global, I read the both in Python doc and it wasn't that clear if the global need to be specified inside the method's class or not as Parameters is defined as global, and outside of the class. What I noticed, is if I do not mention the global in GetDDescription() methods I'm getting error in console saying that Parameters is use prior being assigned, which means somehow Python do not see and look for the global var named Parameters. That error never occurred once global is specified in GetDDescription(), but yes, it is weird.

    I'm keeping you in touch about the next tests.
    Cheers,
    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    Hi @ferdinand,

    For an unknown reason, that does not work. I do not get any errors, but anyways, the sliders MIN/MAX values remains identical to the value sets in Resource file.

    I sat up almost the same code, and so I was wondering if there is a way to reach the c4d.DESC_MIN parameters by correctly setting up the descID of the sliders and use instead the description.SetParameters(descID, param, groupID). I just didn't find the right declaration to get is work.

    For a correct understanding, here the Resource .res,

    // The description defintion of the tag Tmmover.
    CONTAINER Tmmover
    {
      NAME Tmmover;
      INCLUDE Texpression;
    
      // The main "Tag" tab of the tag.
      GROUP ID_TAGPROPERTIES
      {
        // ...
    
        GROUP 
        {
               REAL ID_X           { MIN -100.0; MAX 100.0; UNIT DEGREE; STEP 0.005; CUSTOMGUI REALSLIDER; }
               REAL ID_Y           { MIN -50.0; MAX 50.0; UNIT DEGREE; STEP 0.005; CUSTOMGUI REALSLIDER; }
        }
      }
    }
    

    Code,

    global Parameters
    Parameters = dict()
    Parameters['Xmin'] = -25.0
    Parameters['Xmax'] = 25.0
    
    def GetDDescription(self, node, description, flags):  
           
            global Parameters
    
            if not description.LoadDescription(node.GetType()):
                return False  
    
            # Change Slider limits accordingly to the UserData loaded into the global dict() named Parameters 
            # Sliders to modify: ID_X, ID_Y
    
            ## AXIS X
            paramID_X: c4d.DescID = c4d.DescID(c4d.DescLevel(c4d.ID_X, c4d.DTYPE_REAL, 0))
            singleId: c4d.DescID = description.GetSingleDescID()
                print (f"{singleId = }")
            # Bail when there is a to be evaluated parameter and our parameter is not part off or equal
            # to the to be evaluated parameter.
            if singleId and not paramID_X.IsPartOf(singleId):
                return True, flags
            # Get the description data container instance (GetParameter>I<) for the parameter we want to modify
            desc_X c4d.BaseContainer = description.GetParameterI(paramID_X)
            if desc_X is None:
                return True, flags
                    
            # Write the MAX and MAXSLIDER values based on Parameters values
            print(f"min { Parameters['Xmin'] } / max {Parameters['Xmax']}" )
            desc_X[c4d.DESC_MIN] = Parameters["Xmin"]
            desc_X[c4d.DESC_MINSLIDER] = Parameters["Xmin"]
            desc_X[c4d.DESC_MAX] = Parameters["Xmax"]
            desc_X[c4d.DESC_MAXSLIDER] = Parameters["Xmax"]
    
            # Not Working, no errors, but something should be wrong here
            # How to define SetParameter with the new correct values that are set into the Parameter dictionary?
            # description.SetParameter(singleId, desc_X, paramID_X)
            
    
            return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
    
    

    Help would be appreciated as I do not understand why it is not working while your example is...

    Cheers,
    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    Hi @ferdinand,

    Thanks for clarifying, and I indeed noticed by the past when looking for bugs and printing some values in console that indeed GetDDescription are called multiple time. In my case, the change of the slider values will only occurs once.

    The scene loaded contains some UserData that will be used to set sliders MIN/MAX. Once done, they will be no change needed.
    So in my case the GetDDescription call will still multiple but the changed will be skipped once done. But it is good to indeed clarify this point.

    Cheers,
    Christophe

    posted in Cinema 4D SDK •
    RE: Can REAL MIN / MAX value be changed on Init?

    Hello @ferdinand, Thanks a lot for all the informations. So there is a way to get it work, glad to hear and read all of this!

    I'm going to have a look on this deeper now I have a lead, and see how I can manage this. As I'm going to change those values only once at first run once some UserDatas are loaded, I think the impact on performance will be really limited.

    Have a good day and thanks for the tips!
    Cheers,

    Christophe

    posted in Cinema 4D SDK •
    Can REAL MIN / MAX value be changed on Init?

    Hi there!

    I made a TAG plugin recently, and now I have to use it on different setup. Those changes involve different MIN / MAX values for some REAL represented by a CUSTOMGUI REALSLIDER.

    .res file

    GROUP GR_SLD {
            DEFAULT 1;
        
            REAL OFF_X { MIN -10.0; MAX 10.0; UNIT METER; STEP 0.001; CUSTOMGUI REALSLIDER;  }
            REAL OFF_Y { MIN -10.0; MAX 10.0; UNIT METER; STEP 0.001; CUSTOMGUI REALSLIDER;  }
    }
    

    I was wondering if there is a way using SetParameter to reach those value and change them dynamically as they are typically hardcoded in the Resource file.

    If yes, what is the correct descID, ie Description ID to reach them? For example to setup the Aperture on Camera GUI I'm doing it this way

    descID = c4d.DescID(c4d.DescLevel(c4d.CAMERAOBJECT_FNUMBER_VALUE, c4d.DTYPE_REAL, 0))
    self.Camera.SetParameter(descID, dataNode.GetFloat(LENS_FSTOP), c4d.DESCFLAGS_SET_USERINTERACTION)
    

    Is there some kind of magic to change the MIN : -10.0; value on the User Interface upon initialization of the plugin in Python?

    Thanks a lot to help me to clarify this point.
    Cheers,

    Christophe

    posted in Cinema 4D SDK •
    RE: [SOLVED] ARROWBUTTON resource not accessible for Python?

    It does the trick, thanks a lot @ferdinand !
    Cheers,
    Christophe

    posted in Cinema 4D SDK •