# Get_last_id of the substracted volumes

I am attempting to obtain the ids of the subtracted volume and tool volume.
The following is what I am woking on, but I can only obtain the id of the tool volume. Please let me know how.

``````cubit.reset()
cubit.cmd('brick x 10 ')
cubit.cmd('create Cylinder height 10 radius 2 ')
cubit.cmd('subtract volume 2 from volume 1  keep_tool imprint')

id_volume = cubit.get_last_id('volume')
print(id_volume)
``````

Hi @ksugahar,

it is possible, but we would need to work with bodies.

First some geometry

``````#!python
cubit.reset()
cubit.cmd('brick x 10 ')
cubit.cmd('create Cylinder height 10 radius 2 ')
cubit.cmd('webcut volume 1 with plane zplane offset 0')
``````

In the python api we got a subtract() method.

To use it, we need a vector of bodies for the tool and from where we want to subtract. When we subtract we will get a list of bodies that have “changed”. In our case we get the bodies that are holding the new volumes. We probably won’t need the original volumes anymore, so we are going to delete them. The tool will be kept. We now got all ids of the involved bodies/volumes.

``````tool_in_ids = cubit.parse_cubit_list('body','all in volume 2')
from_in_ids = cubit.parse_cubit_list('body','all except in volume 2')

tool_in = []
for id in tool_in_ids:
tool_in.append(cubit.body(id))

from_in = []
for id in from_in_ids:
from_in.append(cubit.body(id))

list = cubit.subtract(tool_in,from_in,True,True)

cubit.cmd(f"delete volume {' '.join(str(id) for id in from_in_ids)}")

for body in list:
print(body.id())

print("finished")
``````