Tool doesn't execute until view is selected



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/07/2011 at 11:36, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Hey guys.

    I'm having a problem with the SetPoint tool in a Coffee script(not a plugin).
    I have to click in the main scene view for it to execute.
    Here's the code:

    var obj = doc->GetActiveObject();  
    CallCommand(200000065); // Activate the Set Point Value tool  
    tool()#MDATA_SETVALUE_SETX=1;  
    tool()#TEMP_MDATA_SETVALUE_VAL_X = 300;  
    CallButton(tool(),ID_MODELING_SETVALUE_TOOL);  
    obj->Message(MSG_UPDATE);  
    DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW|DRAWFLAGS_NO_THREAD|DRAWFLAGS_NO_REDUCTION|DRAWFLAGS_STATICBREAK);  
    EventAdd();
    

    I've added the usual things to force C4D to update(Message, DrawViews, EventAdd) but they aren't working.
    Is there some other way I can tell C4D to update and execute the tool when my script is executed?

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/07/2011 at 12:30, xxxxxxxx wrote:

    Never mind.
    I found a different way to execute it that works better:

    var obj = doc->GetActiveObject();  
    CallCommand(200000065); // Activate the Set Point Value tool  
    tool()#MDATA_SETVALUE_SETX=1;  
    tool()#TEMP_MDATA_SETVALUE_VAL_X = 300;  
    CallButton(tool(), MDATA_APPLY);  
    obj->Message(MSG_UPDATE);  
      
    EventAdd();
    

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/07/2011 at 05:12, xxxxxxxx wrote:

    For modeling actions it's best to call the SendModelingCommand().

    here an example:

      
    var obj = doc->GetActiveObject();  
      
    var bc = new(BaseContainer);  
    bc->SetData(TEMP_MDATA_SETVALUE_VAL_X, 300.0);  
    bc->SetData(MDATA_SETVALUE_SETX, MDATA_SETVALUE_SET_SET);  
      
    SendModelingCommand(ID_MODELING_SETVALUE_TOOL, doc, obj, bc, MODIFY_POINTSELECTION);  
    

    PS. I just noticed it's missing in the COFFEE R12 docs. Please refer to the COFFEE R9.5 docs in this case. I will update the COFFEE docs as soon as possible.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/07/2011 at 08:08, xxxxxxxx wrote:

    Thanks Matthias.

    Yes. I thought it was very strange that they were removed from the R12 Coffee docs. I asked around but never got a good answer why.
    I guess it never made it to your desk. I'll contact you directly here in the future about such issues.

    I did try using the SMC first like in your example. But it always sends the selected point to 0.
    For some reason it's not observing the line: bc->SetData(TEMP_MDATA_SETVALUE_VAL_X, 300.0);
    That's why I went with a different method.
    I'd rather use the SMC. But I can't make it work properly.

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/07/2011 at 15:10, xxxxxxxx wrote:

    Indeed it's not setting the the correct value. I have to check why not.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/09/2012 at 06:48, xxxxxxxx wrote:

    Hi i am hat the new her and just stumbled upon this because i got the same problem the TEMP_MDATA_SETVALUE_VAL_X doesn't work. So is there any News on why that is, and how it could be made to work???

    Cheers
    Wuensch



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/09/2012 at 07:54, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Hi i am hat the new her and just stumbled upon this because i got the same problem the TEMP_MDATA_SETVALUE_VAL_X doesn't work. So is there any News on why that is, and how it could be made to work???

    I just found that assigning the ID MDATA_SETVALUE_VAL (vector) in the tool container instead of TEMP_MDATA_SETVALUE_VAL_X works as expected:

    var obj = doc->GetActiveObject();
      
    var bc = new(BaseContainer);
    bc->SetData(MDATA_SETVALUE_SETX, MDATA_SETVALUE_SET_SET);
    bc->SetData(MDATA_SETVALUE_VAL, vector(300.0,0.0,0.0));
      
    SendModelingCommand(ID_MODELING_SETVALUE_TOOL, doc, obj, bc, MODIFY_POINTSELECTION);
    

    And to set the X, Y and Z values:

    var obj = doc->GetActiveObject();
      
    var bc = new(BaseContainer);
    bc->SetData(MDATA_SETVALUE_SETX, MDATA_SETVALUE_SET_SET);
    bc->SetData(MDATA_SETVALUE_SETY, MDATA_SETVALUE_SET_SET);
    bc->SetData(MDATA_SETVALUE_SETZ, MDATA_SETVALUE_SET_SET);
    bc->SetData(MDATA_SETVALUE_VAL, vector(300.0,300.0,300.0));
      
    SendModelingCommand(ID_MODELING_SETVALUE_TOOL, doc, obj, bc, MODIFY_POINTSELECTION);
    

    EDIT: As their name imply, TEMP_MDATA_SETVALUE_VAL_X, TEMP_MDATA_SETVALUE_VAL_Y and TEMP_MDATA_SETVALUE_VAL_Z are just temporary and seems to be only used by the UI of the tool, not by its modelling command (that accesses MDATA_SETVALUE_VAL instead). If you try to assign MDATA_SETVALUE_VAL to the tool, it gives you an invalid description ID error.


Log in to reply