Jump to content
3DCoat Forums

Filling a layer by script


thinkinmonkey
 Share

Recommended Posts

  • Advanced Member

Hello,

I'm writing a simply script to help me creating clip mask layer for the selected one, I don't know if 3DC has a command for it.

So at the moment, I take the current layer name, I create a new layer with the "m_" + the current layer name, but I don't know how to fill the mask layer with a color and how to assign it to the current layer as clip mask. I'm reading the script guide, but I cannot find something useful.

Please, can someone help me? Thank you

The script till now:
 

void main(){
    SetModalDialogCallback("ModalDialogCallback");

    string layerName;

    layerName = GetCurrentPaintLayerName();
    AddPaintLayer("m_" + layerName);
    
    SetPaintLayerOpacity(0);

    // fill the layer

    // assign the layer as clip mask layer to layername

    SelectPaintLayer(layerName);
}

void ModalDialogCallback(){        
}

 

Link to comment
Share on other sites

  • Contributor

This should work:

void main(){
    string layerName;
    
    cmd("$FREEZE_TRANSP_INV");
    
    layerName = GetCurrentPaintLayerName();
    AddPaintLayer("m_" + layerName);
    string maskLayerName = GetCurrentPaintLayerName();

    // Fill the layer with the currently selected material or color.
    cmd("$FILLLAYER1");
    // Hide the mask.
    SetPaintLayerVisibility(false);

    SelectPaintLayer(layerName);
    // Set clip mask.
    cmd("$COMBOBOX_LinkedLayer" + maskLayerName);
    // Remove the freeze.
    cmd("$MENU_UNFREEZE_ALL");
}

Note that it is not possible to select/deselect Smart Materials with scripting, so contents of the mask layer will use whatever material or color you have currently selected. It is okay, as 3D-Coat only looks up opacity when dealing with clip masks. Just make sure your active material or colour doesn't have an alpha.

Edited by ajz3d
Link to comment
Share on other sites

  • Advanced Member

ajz3D,

it seems to me it doesn't work.

What I have is what you see in pictures: it seems to me it fills the painted layer, not the mask layer, which is empty. I tried to apply some of your instructions to my purpose/script, but the results is the same.

Other than that, it doesn't link the mask layer into the clip mask option of the painted layer, it's empty.

I'm using 3DC 4.7.20.

By the way, where can I get a list of all commands you use in the cmd() instruction?

Thank you.

Screenshot_185.jpg

Screenshot_186.jpg

Link to comment
Share on other sites

  • Contributor
2 hours ago, thinkinmonkey said:

ajz3D,

it seems to me it doesn't work.

What I have is what you see in pictures: it seems to me it fills the painted layer, not the mask layer, which is empty. I tried to apply some of your instructions to my purpose/script, but the results is the same.

Other than that, it doesn't link the mask layer into the clip mask option of the painted layer, it's empty.

I'm using 3DC 4.7.20.

That's strange. It works fine on my end (4.7.26). You can try adding Step(1) after each line.

2 hours ago, thinkinmonkey said:

By the way, where can I get a list of all commands you use in the cmd() instruction?

There is no such list. To find a specific command, you must RMB+MMB click on a UI element. It will store its command in clipboard from which you can paste it to your code.

Link to comment
Share on other sites

  • Advanced Member

Ok, I see now, it works, it was a different version number.

I still have strange behavior when using clip masks with layers and I have some corrupted files, I have to show the bug.

Anyway, thank you for your help, really appreciated, I learnt a lot today.

Happy Easter and have a nice weekend too.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...