I want to project the green mesh onto the red one:
Is it possible?
ProjectMesh.gh (55.0 KB)
That mesh doesnāt have enough vertices to match the shape of the target mesh closely. Assuming that is what you want, Iād suggest populating the mesh with points > pull those points to the target mesh > make a new mesh from them like thisā¦
If on the other hand you wanted to keep the same vertex count, you could do it this wayā¦
I hope that helps.
Populating with points is not a solution. Only the necessary points should be added.
And second, Delaunay Mesh is not a solution either, because the original mesh could have holes inside. It consists in modifying the original mesh, but not creating a completely new one.
Anybody else?
I canāt believe such an easy problem canāt be solved by McNeel forum!
Nobody?
All things are relative.
For instance imagine having the Mesh Outline(s) (as Polyline(s) then as Curve(s)) and projecting it/them - IF possible - to the target (thereās a RC Method available anyway PLUS other tricks if the target has weird Topology). Now the question is: do you want to split (so to speak) the target (thus having a result that is a āportionā of the target) OR do business with the Mesh to project? - kinda a ādrapeā thing (thatās slightly more challenging notably if the target is weird).
Bad news: if Iāll provide some indicative solution that would be done purely via code (C#) meaning either heaven or hell depending on your point of view.
I think thatās enough. However, as you can see in the example, that outline can exceed the limits of the other mesh.
Thatās not a big deal. But you havenāt answer the 1M question: what kind of result? a āportionā of the target OR a draped (so to speak) Mesh? (kinda like the drape effect that K2 can do - see lotās of examples around IF this is the desired result).
I donāt mind (if I have understood the question). Obtaining an individual mesh projected on the other one would be enough.
Thatās in theory. If the Mesh (and the resulting projected Outline(s)/Crv(s)) are partially outside the target the result would be a collection of splitted pieces.
Anyway Iām not in the practice right now. When back Iāll post an indicative take on that matter - as a āgeneral caseā as possible - where the Mesh yields a splitter that splits the target etc etc.
If one needs only the target pieces inside the splitter ā¦ well ā¦ that requires an elementary inclusion check (since the splitter is closed [derived from a Mesh from Brep ā¦ derived using the CreateFromOffsetFace Method]).
BTW: Appears that the ādrapeā approach is not the ideal way to cut the mustard assuming a weird/freaky target. So the Mesh acts like a cutter and the focus is on the target Mesh.
Thank you, I look forward to that indicative post.
Get a rather simple take on that puzzle. A K2 242 ārelaxationā is included - but if you need an āaccurateā rasult ā¦ well ā¦ disable it.
Mesh_ProjectToAnother_EntryLevel_V0.gh (350.9 KB)
Not quite.
The C# works by shooting a Ray3d from each Mesh Vertex to the target (given obviously a user defined Vector). Each shoot either yields a Point or null. So the āhitā collection is a nullable one. The order is exactly the same as the one in Mesh Vertices.
Then for each Face in the Mesh ā¦ if ALL the adjacent Vertices have corresponding (by index) non null hit Points ā¦ then a new Mesh Face is created and added to the result Mesh.
Obviously the result is heavily related with the 2 Topologies AND the Ray3d direction. If you want a finer result subdivide the Mesh ā¦ or the result (but the latter may be very tricky - general case: any Mesh pair VS any Ray3d etc etc).
It sounds like you might want to split the larger mesh by the naked perimeter of the smaller mesh? I donāt know if these methods are implemented in native Grasshopper, but one can certainly script them fairly easily:
Note that I moved the meshes to the origin, as mesh operations are prone to floating point issues.
Exactly what I needed. Thank you so much!
Hello @AndersDeleuran .
Iāve slightly modified your code to obtain all mesh fragments, but, in essence, the flow is the same.
Iāve been trying to use that script inside a Hops component. However, the script gets stuck in the middle. I added two debug outputs (plcA
and plcB
).
As you can see, plcA
output is ok, but not the same for plcB
. Probably due to an error with rg.Curve.ProjectToMesh(plcA, MeshA, Vector, 0.001)
.
Does anybody know how to solve it? Any help would be appreciated
test_mesh.gh (501.7 KB)
test_mesh_Hops.gh (3.5 KB)
Really nobody?
I just tried running the files and got the same result as you. I donāt really know anything about/use Hops, so Iām afraid I can help debug why it might fail.