# Mel scripting help?

**URL:** https://forum.highend3d.com/t/mel-scripting-help/151515
**Category:** Animating & Rigging
**Created:** [February 9, 2017, 2:32pm UTC](https://forum.highend3d.com/t/mel-scripting-help/151515 "2017-02-09T14:32:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zero\_steph](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/z/3e96dc/32.png) [@zero\_steph](https://forum.highend3d.com/u/zero_steph)
#### Post date: [February 9, 2017, 2:32pm UTC](https://forum.highend3d.com/t/mel-scripting-help/151515/1 "2017-02-09T14:32:15Z")

</div>

Hello,

I was wondering if someone could help me write a MEL script that would allow me to do this:

select objectA  
if objectA does not exists, then skip  
if objectA exists, then put in on a Layer and rename it LAYER\_A  
if LAYBER\_A already exists, then skip

select objectB  
if objectB does not exists, then skip  
if objectB exists, then put in on a Layer, rename it LAYERB.  
if LAYERB already exists, then skip

Thank you!

---

<div class="post-metadata">

### Author: ![mehdi-louala](https://forum.highend3d.com/user_avatar/forum.highend3d.com/mehdi-louala/32/4383_2.png) [@mehdi-louala](https://forum.highend3d.com/u/mehdi-louala)
#### Post date: [February 9, 2017, 3:04pm UTC](https://forum.highend3d.com/t/mel-scripting-help/151515/2 "2017-02-09T15:04:45Z")

</div>

Hi zero\_steph,

Here is your MEL script =), (but Python is best ! 🙂)

> [@mehdi-louala](#):
>
> string $obj = “nurbsCircle1”; // here is the name of objectA  
> string $layerA = “LAYER\_A”; // here is the name of your layerA  
> if (objExists($obj)) {  
> if (!objExists($layerA)) {  
> select $obj; // select the object before creating the layer  
> createDisplayLayer -n $layerA -noRecurse;  
> }  
> }

You can apply the same principle for **objectB** and **LAYER\_B** by replacing the text between the double quotes on the beginning of the script  
Peace,  
Mehdi

---

<div class="post-metadata">

### Author: ![zero\_steph](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/z/3e96dc/32.png) [@zero\_steph](https://forum.highend3d.com/u/zero_steph)
#### Post date: [February 9, 2017, 4:12pm UTC](https://forum.highend3d.com/t/mel-scripting-help/151515/3 "2017-02-09T16:12:50Z")

</div>

That worked great, thank you very much!
