# How to get points from Magnet SOP

I am trying to get the points the Magnet SOP is modifing but there is not methods in its class to get them.

I don’t know if the documentation wasn’t filled or there are really no methods.

Does anyone know how to get the methods of a class?

Thank you

As in only the points that have changed or all the points from the metaball SOP?

The magnet SOP inherits from the SOP class, so you can still use something like:
op('magnet1').points to get all the points from your magnet SOP.

If you want only the changed points, you’d have to do a little extra work - you could convert to CHOPs, check there, then convert back to a SOP - or you could do that in a script SOP.

Hello raganmd,

I would like to get only the points the Magnet SOP is changing.
The ideal would be also with the force applied on each of them.

I have tried to get something similar with Ray SOP, but it is not really the same thing and it doesn’t perform on big meshes. On the other hand it seems the Magnet SOP would do a perfect job.

What I really want to do is to keep the position of the points the Magnet changed and create a new mesh with all the new positions.

Thanks for the support. And also thank you for all the amazing tutorials on youtube! They are very inspiring.

I don’t know how re-usable this approach would be, but it might be a starting point for you in thinking about how to approach this particular puzzle.

We start with a grid that we’ve deformed with a magnet. We’ll need null SOPs that point to both of these:

Next you’ll convert both of these to CHOPs (I think the math here will be faster to perform in CHOPs than in Python):

.

To figure out who has changed we need to think of that coordinate as a single value - we can use the length of a vector as a comparison here. We can use a math CHOP to compute the length of each input CHOP, then subtract the two lengths from one another. If the value of the length of the vector is equal between points we’d end up with a result of 0, anything else is a point that’s changed:

We’ll rename this channel to “keep”, and merge it in with the CHOP data form our magnet SOP:

To find out how much a point has changed, we can do something similar - this time we’ll take both SOP to CHOPs, and subtract them from one another, then derive the length of the result. We can then rename this to "dispForce’ and merge it with our SOP to CHOP data:

Next we’ll use a delete CHOP to remove any samples that are greater than 0 (we need to make sure we’re looking at the “keep” channel:

Next we can covert back to SOPs - we can use the dispForce channel we created and assign it to the point weight attribute of the converted points. A convert SOP will convert this into just points rather than a connected set of points. A SOP to DAT let’s us confirm that we’ve correctly assigned a value to our point weight attribute:

That doesn’t get you a mesh, but it does get you all the changed points and a sense of how much they’ve changed. Building a mesh will be a little tricky - it’d be easy to end up with an odd number of points. How you map these back into polygons would take a little extra work. Hopefully this will get you started though:

base_changed_points.tox (1.5 KB)

That was really helpful. Thank you so much.

I was thinking there was a faster way. Since I believe there would be def a function inside the Magnet Class that will return those points.

But that is a good solution anyway.
And moreover I already know how to create the mesh. I do a SOP to DAT and DAT to SOP operation.

I will upload the file when it is done.

Thanks again!