# Is there any way to create a model with several components in CLI

**URL:** https://discourse.slicer.org/t/is-there-any-way-to-create-a-model-with-several-components-in-cli/25313
**Category:** Support
**Created:** [September 17, 2022, 6:18am UTC](https://discourse.slicer.org/t/is-there-any-way-to-create-a-model-with-several-components-in-cli/25313 "2022-09-17T06:18:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![wpgao](https://avatars.discourse-cdn.com/v4/letter/w/8e8cbc/32.png) [@wpgao](https://discourse.slicer.org/u/wpgao)
#### Post date: [September 17, 2022, 6:18am UTC](https://discourse.slicer.org/t/is-there-any-way-to-create-a-model-with-several-components-in-cli/25313/1 "2022-09-17T06:18:50Z")

</div>

Is there any way to create a model with several components, and each component (a mesh model) with different color in CLI. Then, output the model and automatic loaded by Slicer.  
Thanks!

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 17, 2022, 3:26pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-create-a-model-with-several-components-in-cli/25313/2 "2022-09-17T15:26:58Z")

</div>

Yes, you can look at the ModelMaker module. It’s slightly legacy at this point since we move to the Segmentation infrastructure but it still works to convert labelmaps to multiple colored models (meshes).

---

<div class="post-metadata">

### Author: ![wpgao](https://avatars.discourse-cdn.com/v4/letter/w/8e8cbc/32.png) [@wpgao](https://discourse.slicer.org/u/wpgao)
#### Post date: [September 18, 2022, 1:12am UTC](https://discourse.slicer.org/t/is-there-any-way-to-create-a-model-with-several-components-in-cli/25313/3 "2022-09-18T01:12:48Z")

</div>

> [@pieper](#):
>
> orks to convert labelmaps to multiple colored mod

Thanks Steve! It’s a good suggestion. I developed a CLI using python, Slicer can be imported, but its modules cannot be found. Is it possible to save the model with color into a single vtk file and loaded it in Slicer? I had tried but the model can be loaded without color information.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 18, 2022, 4:26pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-create-a-model-with-several-components-in-cli/25313/4 "2022-09-18T16:26:49Z")

</div>

You can make a single VTK polydata file with scalar colors but they won’t be turned on by default (user would need to turn them on in the Models module). The way the ModelMaker works is by writing out a mini-mrml scene that includes the color information for each polydata. The CLI infrastructure is intended to make it easy to do simple things, but if you need to do something more complex you might want to put the implementation in a module logic instead so you can use the full Slicer API.

---

<div class="post-metadata">

### Author: ![wpgao](https://avatars.discourse-cdn.com/v4/letter/w/8e8cbc/32.png) [@wpgao](https://discourse.slicer.org/u/wpgao)
#### Post date: [September 19, 2022, 1:29am UTC](https://discourse.slicer.org/t/is-there-any-way-to-create-a-model-with-several-components-in-cli/25313/5 "2022-09-19T01:29:50Z")

</div>

Did you mean that if I want to use the full SlicerAPI, I should implement the module as a loadable module or scripted module rather than a CLI?

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 19, 2022, 12:41pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-create-a-model-with-several-components-in-cli/25313/6 "2022-09-19T12:41:07Z")

</div>

Yes, that’s right. CLI modules are a special case.
