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 aTransformobject. - Performance: Since
SubDtransformation 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