Then this imported function makes some modifications with this Mesh Reference. I’m sure that they are because I perform an inspect for that.
After that while making just the exact same inspection but in the main script it turns out, that the original mesh remains the same.
I’m just missing something important… how do I update original Mesh with its modified reference?
I seem to have found a way to achieve the desired result: just create a new Mesh from this modified reference, and delete the old one.
But I’m not sure if this is the most graceful solution.
However, it works, so be it.
I am very sorry to bore you with ridiculous questions, and yet I would be very grateful if someone could explain to me such a simple thing:
When I select an object using sc.doc.Objects.FindGeometry and get its reference, it means that I get a kind of copy of the object, but not the object itself !? Therefore, I need to commit all changes through deleting the old object and creating a new one from this modified reference?
For example, if I changed coordinates of a vertex in a Mesh, is this the correct way, or there is another better and correct way to do it?
Mesh_Ref = Rhino.DocObjects.ObjRef(Mesh_Guid)
Mesh_Itself = Mesh_Ref.Mesh()
print(Mesh_Itself.Vertices) # prints 1,1,1
Mesh_Itself.Vertices.Item = rhg.Point3f(100, 100, 100)
print(Mesh_Itself.Vertices) # prints 100,100,100
but viewport Mesh remains. I also tried this kind of “direct surgery” variant, but without succes:
Rhino.DocObjects.ObjRef(Mesh_Guid).Mesh().Vertices.Item = rhg.Point3f(100, 100, 100)
Mesh_Itself.Vertices.Item.X = 100 # does not SET
print(Mesh_Itself.Vertices.Item.X) # but gets fine, prints 1
though it says “Gets or sets the X (first) component of the vector” here
Thank you @Dale,
so, adding new Mesh anyway, as I understand, no way to modify existing one!? If I would like to make some simple animation with mesh vertices moving, it means that I need to delete the previous mesh and AddMesh for each iteration…, am I right? Basically, thats ok, I’ll live with that.
I got another question, please help: how do I make an independent copy of Mesh.Vertices?
while I need
copy.deepcopy doesnt work with mesh.vertices… I also found MemberwiseClone in MeshVertexList class, but I dont uderstand how it works
Of course I can iterate through each vertex and append it to some empty list, but I hoped theres some faster way…
:)) Thank you @AndersDeleuran
it does work how intended. ToPoint3fArray to be exact
In my defense, I will say: on a MeshVertexList info page I searched for the word “copy” and there is no such word in a description of ToPoint3fArray method… it has “Copies”
MemberwiseClone has… so Im only halfly dumb