# How to create a Resource from a file I loaded with a custom ParaView reader?

**URL:** https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645
**Category:** Simulation Modeling Toolkit (SMTK)
**Created:** [November 14, 2025, 9:23am UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645 "2025-11-14T09:23:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/c/76d3ee/32.png) [@CsatiZoltan](https://discourse.kitware.com/u/CsatiZoltan)
#### Post date: [November 14, 2025, 9:23am UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645/1 "2025-11-14T09:23:16Z")

</div>

Hi,

I ported my reader-type ParaView plugin to CMB without any change. It works fine, but the imported mesh does not appear in the “Resources” panel. How can I implement a plugin that imports the mesh in the resources, each mesh part (e.g. a block corresponding to a boundary segment) appears in the resources? As far as I understand, this is needed so that I can work with SMTK.

I would like to mimic the behaviour when I open, for instance, a .mesh file in Truchas, it offers to import it into `smtk::session::vtk::Resource`. Opening the same file in ParaView, I see that it was the IOSS reader that loaded it as a `vtkPartitionedDataSetCollection` object.

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [November 16, 2025, 5:04am UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645/2 "2025-11-16T05:04:18Z")

</div>

You would need to modify the Import operation of SMTK’s VTK session (or other resource types, such as the markup resource) to use your VTK reader and create SMTK components for each piece of geometry you want to be its own object.

---

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/c/76d3ee/32.png) [@CsatiZoltan](https://discourse.kitware.com/u/CsatiZoltan)
#### Post date: [November 16, 2025, 7:45am UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645/3 "2025-11-16T07:45:37Z")

</div>

Is it documented or is there an example somewhere? I guess this is the most important step; if I don’t have my mesh represented as a Resource, I cannot use most of the functionalities of SMTK/CMB.

---

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/c/76d3ee/32.png) [@CsatiZoltan](https://discourse.kitware.com/u/CsatiZoltan)
#### Post date: [November 17, 2025, 4:34pm UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645/4 "2025-11-17T16:34:32Z")

</div>

After investigating more, I would have further questions:

1. What is the difference between [`ImportResource`](https://smtk.readthedocs.io/en/latest/doc/reference/smtk/html/classsmtk_1_1operation_1_1ImportResource.xhtml) and [`ReadResource`](https://smtk.readthedocs.io/en/latest/doc/reference/smtk/html/classsmtk_1_1operation_1_1ReadResource.xhtml)? One can read this in the tutorial:

```plaintext
Standard practice would use the SMTK ImportResource or ReadResource operations to load attribute and other resources.

```

2. How can I import/read from memory instead of a file? My ParaView reader plugin read my file type as a `vtkUnstructuredGrid` object; this is what I would like to represent as a resource.
3. Can we import/read from multiple files (or preferably: VTK objects in memory) into the same resource? Use case: probably I will represent the different parts of a body (subdomains, boundary surfaces) as separate `vtkUnstructuredGrid` objects. Then I would like to combine them in a single resource, i.e. they are in the same tree of the _Resources_ panel of CMB.

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [November 17, 2025, 5:12pm UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645/5 "2025-11-17T17:12:50Z")

</div>

> [@CsatiZoltan](#):
>
> What is the difference between [`ImportResource`](https://smtk.readthedocs.io/en/latest/doc/reference/smtk/html/classsmtk_1_1operation_1_1ImportResource.xhtml) and [`ReadResource`](https://smtk.readthedocs.io/en/latest/doc/reference/smtk/html/classsmtk_1_1operation_1_1ReadResource.xhtml)

A resource is not a VTK data object. A resource is an SMTK object representing a “document.” Resources hold zero or more components (also SMTK objects, not VTK objects). SMTK resources are stored as JSON. An operation that **reads** a resource parses JSON data in SMTK format to create an in-memory version of the document (resource plus its components). An operation that **imports** into a resource parses data in some non-SMTK format to populate components into either a new or an existing SMTK resource. You would not use a read operation to load data that is not in SMTK’s JSON format.

SMTK components may each own VTK objects.

> [@CsatiZoltan](#):
>
> How can I import/read from memory instead of a file? My ParaView reader plugin read my file type as a `vtkUnstructuredGrid` object; this is what I would like to represent as a resource.

You cannot use VTK objects as SMTK resources. You can create SMTK resources that own VTK objects.

In CMB, you would not use ParaView to load the data directly; instead, you would define an **import** operation that instantiates your reader, constructs a resource (if one is not provided to the operation by association), and then constructs a component for each VTK object of concern. For example, your reader might produce a `vtkPartitionedDataSetCollection`, but instead of creating a single output SMTK component, you might create an SMTK component for each entry of the `vtkPartitionedDataSet` instances. Or you might use the `vtkDataAssembly` of the partitioned dataset collection to create components and associate multiple VTK data objects to each component. On the other hand, if your reader produces a `vtkUnstructuredGrid`, you might produce a single component.

> [@CsatiZoltan](#):
>
> Can we import/read from multiple files (or preferably: VTK objects in memory) into the same resource? Use case: probably I will represent the different parts of a body (subdomains, boundary surfaces) as separate `vtkUnstructuredGrid` objects. Then I would like to combine them in a single resource, i.e. they are in the same tree of the _Resources_ panel of CMB.

Yes. Depending on how your import operation is called, the result is that you can have multiple VTK objects from different files in a single resource or spread across multiple resources.

---

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/c/76d3ee/32.png) [@CsatiZoltan](https://discourse.kitware.com/u/CsatiZoltan)
#### Post date: [November 17, 2025, 5:41pm UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645/6 "2025-11-17T17:41:49Z")

</div>

Thank you for the detailed reply, now I understand the distinction between **import** and **read**. So the JSON file is the .smtk file, which, as I noticed, contains reference to the actual mesh file.

> Resources hold zero or more components

What is a resource component in SMTK?

> In CMB, you would not use ParaView to load the data directly; instead, you would define an **import** operation that instantiates your reader

OK, so it means that I need to write an additional layer that wraps my existing reader. Can you point to me example(s)? I found [use cases for `ImportResource`](https://gitlab.kitware.com/search?group_id=27&project_id=148&repository_ref=master&scope=blobs&search=importresource), but not on what you wrote previously:

```plaintext
You would need to modify the Import operation of SMTK’s VTK session (or other resource types, such as the markup resource) to use your VTK reader

```

> if one is not provided to the operation by association

What do you mean by association?

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [November 18, 2025, 4:45pm UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645/7 "2025-11-18T16:45:04Z")

</div>

I will try to find (or write) an example in the next day or two, but have some deadlines to deal with right now.

---

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/c/76d3ee/32.png) [@CsatiZoltan](https://discourse.kitware.com/u/CsatiZoltan)
#### Post date: [November 24, 2025, 2:36pm UTC](https://discourse.kitware.com/t/how-to-create-a-resource-from-a-file-i-loaded-with-a-custom-paraview-reader/1645/8 "2025-11-24T14:36:52Z")

</div>

> [@dcthomp](#):
>
> You would need to modify the Import operation of SMTK’s VTK session (or other resource types, such as the markup resource) to use your VTK reader and create SMTK components for each piece of geometry you want to be its own object.

I am getting closer to it, as shown in [How to import a .vtu file programmatically? - #2 by CsatiZoltan](https://discourse.kitware.com/t/how-to-import-a-vtu-file-programmatically/1650/2)  
Is there a way to extend (subclassing or other way) `smtk::markup::Import` (the VTK session cannot import a .vtu file, as I noted in my other post) instead of modifying the source code (that way, I would have to be up-to-date with the SMTK git repo)?
