0
$\begingroup$

I have Added a Color ramp in my node editor using a Script and I wan't that the Color Stops That Are Available by default Should be Deleted. before I add new stops I know how to add new stops but i don't Know how to remove the stops that are there by default using Python script. Can Anyone Help me Out Please

$\endgroup$

1 Answer 1

1
$\begingroup$

You can remove them but not the last one.

If cr_node is the color ramp node, stops are stored in cr_node.color_ramp.elements.

You can remove the element n by:

cr_node.color_ramp.elements.remove( cr_node.color_ramp.elements[n] )

But if you attempt to remove the last one, you will have this error message:

RuntimeError: Error: Element not found in element collection or **last element**

So you need to keep it and change its values:

cr_node.color_ramp.elements[0].color = your color
cr_node.color_ramp.elements[0].position = your position
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .