thinkinmonkey

Filling a layer by script

5 posts in this topic

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(){        
}

 

Share this post


Link to post
Share on other sites

Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now