TransformComponentindex for subd like Brep

In RhinoCommon, the SubD class and its components, like vertices and faces, provide some parallels to the Brep class and its operations, but they don’t always have a one-to-one correspondence in terms of available methods and properties. The TransformComponent method you’re referring to is specifically available for Brep objects, which allows for transformation operations on specific components of a Brep.

Currently, there is no direct equivalent to TransformComponent in the SubD class that allows you to directly transform specific components (such as faces) of a SubD object using ComponentIndex like you can with Brep.

However, you can manually apply transformations to SubD vertices using transformation matrices. Here’s a basic approach to how you could apply a transformation to each vertex of a SubD:

private void RunScript(
    SubD subd,
    Transform xform,
    ref object a)
{
    // Iterate through each vertex of the SubD object
    foreach (SubDVertex vertex in subd.Vertices)
    {
        // Transform the control net point of the vertex
        Point3d pt = vertex.ControlNetPoint;
        pt.Transform(xform);
        vertex.ControlNetPoint = pt;
    }
    
    // Clear the evaluation cache to make sure the SubD updates correctly
    subd.ClearEvaluationCache();

    // Output the transformed SubD
    a = subd;
}

Key Considerations:

  • Vertex Transformations: we can transform SubD vertices, not faces directly. To modify the position of a face, we’ll need to modify its vertices.
  • Transformation Matrix (xform): This can be a scaling, rotation, translation, or any other transformation defined by a Transform object.
  • Performance: Since SubD transformation operations might involve iterating over many vertices, this can be computationally expensive, especially for large objects. Use threading or optimization carefully if performance becomes an issue.

It’s important to periodically check the RhinoCommon API documentation and updates from McNeel, as newer versions may add more direct methods for these operations.
.
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.brep/transformcomponent

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.subdface/componentindex
I request that this feature be added for subd like brep .in Rhino common

Hi @arcarc60,

I’ve logged your request.

https://mcneel.myjetbrains.com/youtrack/issue/RH-83674

– Dale

1 Like

Thanks,I also request that: for SubD.Edges Add ComponentIndex for Transform() Like SubD.Face.ComponentIndex()
And Brep.Edges[index].ComponentIndex();

var co=subd.Faces.Find(i).ComponentIndex();{True}
var eg=subd.Edges.Find(2).ComponentIndex();{False}
error{'SubDEdge' does not contain a definition for 'ComponentIndex'}

or
suggest that it is available{Set} for

var eg=subd.Edges.Find(2).ControlNetLine;{*now in Sdk only ****get;****}

and i suggest available{'get;|set;'}

 subd.Edges.Find(2).ControlNetLine=eg;{'get;|set;'}

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.subdedge/controlnetline

I can fix.

– Dale

1 Like

thanks @dale
and it is very useful if add this:
ComponentIndex().Extrude.face(d…);
(like Rhino)

 subd.Faces.find(index).Component.index().extrude.Face;