SubD from Mesh, how to crease specific points

Hello,

This issue is kind of continuation of an issue solved before, but now involving subd - regards this, there is another issue now.
I would like to know a way to transform a mesh into a subd and crease some points (vertices) in grasshopper. I managed to crease some points in rhinoceros manually, but I would like to make this automatic in grasshopper.

crease_loop_round_shape

As the image shows, there is creases forming loops, making a round crease shape, but actually I would like to have straight crease. This is achieved when creasing the vertices manually after baked the subd geometry, as the image shows:

creased_points_manually

But, I would like to control the output in grasshopper, putting as many creased points as necessary (principally to achieve the result obtained manually), also determining their locations.
Is there a way to do this in grasshopper’s components? A plugin could be useful? Or maybe a script could be made to solve that?

I saw some script along the forum, but they does not work for my case.

This is the .gh file I am working on:

subd_from_mesh_to_crease.gh (52.1 KB)

Thanks a lot for any help.

You’ll have towels the vertices. Try the search function there are a few topics about it

I tried a python script made with the help of ChatGPT (sorry, but I am a newbie in python and other languages, I barely know how to print “Hello, World!”), but it does not work (I kind of looped through ChatGPT’s responses to get the desired result to fix the errors, but the result is still a rounded crease).

import Rhino
import rhinoscriptsyntax as rs

# Inputs:
# subd_geometry: SubD geometry (input from the SubD component)
# points: List of points (Type: Point3d, list of points to apply crease)

# Initialize list to store the indices of the vertices to be adjusted
crease_vertices = []

# Debug: Check the types of the inputs
if subd_geometry is None:
    print("subd_geometry is empty or not connected properly.")
else:
    print(f"subd_geometry is connected. Type: {type(subd_geometry)}")

if points is None:
    print("points is empty or not connected properly.")
else:
    print(f"points is connected. Type: {type(points)}")

# Ensure 'points' is a list
if not isinstance(points, list):
    points = [points]

# Iterate over the specified points and find the closest vertex
for pt in points:
    if not isinstance(pt, Rhino.Geometry.Point3d):
        print(f"Invalid point detected: {pt} (Type: {type(pt)})")
        continue  # Skip to the next point if the current one is not Point3d
    
    closest_index = -1
    closest_distance = float("inf")
    
    # Iterate over the vertices of the SubD
    for i in range(subd_geometry.Vertices.Count):
        vertex = subd_geometry.Vertices[i].Location
        dist = pt.DistanceTo(vertex)
        
        # Check for the closest vertex
        if dist < closest_distance:
            closest_distance = dist
            closest_index = i
    
    # Define a maximum tolerance to consider a vertex as close
    tolerance = 1  # Adjust as necessary
    
    if closest_distance <= tolerance:
        if closest_index not in crease_vertices:
            crease_vertices.append(closest_index)
            print(f"Vertex {closest_index} is close to {pt} (Distance: {closest_distance})")
    else:
        print(f"No close vertex found for {pt} (Minimum Distance: {closest_distance})")

# Apply the crease to the found vertices
if crease_vertices:
    for idx in crease_vertices:
        # Apply crease with weight 1.0 (can adjust as necessary)
        subd_geometry.SetVertexCrease(idx, 1.0)
    print(f"Applied crease to vertices: {crease_vertices}")
else:
    print("No vertex received the crease.")

# Output the updated SubD
a = subd_geometry

python_script_to_crease.gh (392.6 KB)

It told me to increase the tolerance in the search for a vertex relative to the given set of points, but that does not work either. I checked the distance between the vertices of the subd and the given points, and apparently all of them can be reached within a tolerance radius of ‘1’, as the script shows.
Also, it returns 20 equal results (the same amount of points in the point component, even flattened).

Maybe there is a way to solve this based on what Chat created?

I was messing with some components to see which vertices have creases, and apparently the vertices I want to crease are already creases, so I do not understand what is happening, I am probably misunderstanding.

subd_from_mesh_to_crease_01.gh (55.0 KB)

(I do not understand the idea of “have towels the vertices”).

Look at this topic / file

Thank you very much, Martin, but I have already tested the script before this topic. On the other hand, I was thinking that I needed the endpoints of the edges to crease at that moment, not the midpoints, but that still does not work. They are creased, but forming a round shape, before and after passing through the script. Maybe, I am still doing something wrong.

subd_from_mesh_to_crease_02.gh (62.4 KB)

The script uses the midpoints to identify the edges which need to be creased.

It does not crease the midpoints…

Yes. I tried another way: I baked the subd, then creased the points, resulting in the second image of this topic again. After that, I selected the subd in grasshopper and saw that there are no more creases in the vertices that I had creased manually, but actually ‘corners’. In a basic search, I discovered that subds have 4 types of vertices: smooth, crease, dart and corner. Filtering the information, I saw that now the vertices with crease applied have become these corners. So, I need a code to transform these vertices into ‘corners’. On the other hand, I can imagine that it is possible to create the subd from a mesh already with these ‘corners’, but I don’t know how to do that.

I saw that, when setting ‘true’ to sharp in the TriRemesh component, the subd creates ‘corners’, but that’s not exactly what I would like to have in the final shape (it needs to have ‘corners’ only in the steps, as the obtained mesh had, to have smooth plateaus). This is related to the creation of the mesh. Maybe another way of creating the mesh can also solve this problem.

Playing around with the subd components, I saw something called ‘SubD Vertex Tags’, to modify a subd with indexes and tags (smooth, crease, corner, dart): I proceeded with that to apply ‘corner’ to specific vertices. Nothing happens, it just creates an invalid subd and, filtering the corners, something strange occurs, messing up the location of the corners that I would like to become ‘corners’ (even applying individually each vertex to become a ‘corner’, it does not work).

subd_from_mesh_to_crease_03.gh (61.2 KB)


An issue is related here:

SubD vertex tag method not working properly

What’s the reason you want to turn this landscape into a SubD?

You coiuld just refine the mesh and maybe smooth it a bit…

Or stick with Nurbs completely…

Thanks for your examples, Martin. The intention was to have like a perfect plateau for buildings, like boxes on a surface. This surface is a topography, so that when making a section, the boundary of the building will fit exactly with the boundaries of the plateaus (if the plateaus are so smooth, like a round shape, it will not align). On the other hand, everything else needs to be smooth, like a topography is - the plateaus are human-made cuts, with sharp edges, not natural like natural topography is). So in my thinking, with a subd, I would achieve this smoothness and sharpness edges at the same time.

This topic could tell more about what I’m looking for, as I said at the beginning of the this topic: How to create a smooth mesh plateau.

By the way, how did you achieve this result with mesh and nurbs? These are good results, and I could use them.

1 Like

The nurbs approach is done with lofted offset face edges.

Sorry for the late reply Martin, I just left the topic aside to focus on other issues. I tried your approach but did not get the result from your screenshot. Can you show me your workflow?

There you go:

nurbs_approach_mrtn.gh (36.5 KB)

1 Like

Thank you, Martin, I really wouldn’t imagine taking your approach. Great!

1 Like

Hahahaha