Cage editor or morph control to surface

Hello!
I want to create a cage and a cage editor to transform the selected nurbs surface via c# , but I couldn’t find any usage of cage and cage editor in sdk library. I also got another ideal of that. Making cage editor’s control points move, and then gets transformation.
is it possible? because I don’t know how to move the objects if you don’t assign the object type(like point,curve,surface …)

I also read this sample before. http://wiki.mcneel.com/developer/sdksamples/cageedit
it was successful in c++ , so I think it must can be done by c# , but there were some error in transferring to c#
i.e : RhinoCaptureObject( control_object, const_cast<CRhinoObject*>(captive) ); This doesn’t appear to be exposed in Rhino 4.0’s .NET toolkit, so I can’t assign captive object.

Unfortunately, there is not a way to setup and perform cage editing in RhinoCommon yet. It’s on the to-do list, but you probably won’t see this feature added until Rhino 6.

okay, I see .
but it is available on c++, is it?(I mean that morph control sample) ,and why can I transfer it to c#?

My english is not so good, but I really need a help to finish my thesis, Thanks for your patient reply .

I think I need to explain what I am doing now:
I tried to change the surface geometry(ship) automatically by using algorithm (written by c# ).
I tried to move the surface control point to lead transformation, but this method can not change the shape, only let surface be longer or bigger . if I move the control points separately, the shape would change too much and become unsmoothly.
This way I need cage editor to change the surface.If it not work , do you have any suggestion to lead transformation?

You might consider using C++, were cage editing is supported.

ok ! I will try it , but I want to know if c++ sdk can be packed as .dll type and let C# to call?

Yes this is possible. But it can be complicated to setup the solution. But once its setup, you can easily add methods and such.

The following sample solution demonstrates how to share a common library between a Rhino C++ plug-in and a C# RhinoCommon plug-in.

In this example, the RhinoCommon plug-in calls C++ functions using a method called p/invoke.

http://msdn.microsoft.com/en-us/library/aa446536.aspx

A lot to digest - review the sample project carefully.

Is cage editing of some type by now available in Rhinocommon in Rhino 6 WIP?

Gonna bump this thread: I wanted to modify a cage in Python but that doesn’t seem to be working.

The docs are kind of ambiguous. There are some Rhinocommon methods concerning cages, but only as referenced by their grips, however calling rs.EnableObjectGrips or ObjectGripCount on a cage doesn’t work.

If I call rs.GetObject with rs.filter.cage (134217728) nothing can be selected. If I use filter 0 and select a cage, ObjectType on the cage returns 131072 which is MorphControl.

If I use rs.GetObject with rs.filter.grip, I can select a cage grip and it has ObjectType 1 (point), but calling MoveObject on the grip/point has no effect.

Any hope here? Or are cage points not really grips and I’m just coming at this wrong?

Thanks,
Bathsheba

Hi @Bathsheba,

This sample demonstrates how to move some grips:

import Rhino
import scriptcontext as sc

def test_move_grips():
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt('Select grips to move')
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Grip
    go.GetMultiple(1, 0)
    if go.CommandResult() != Rhino.Commands.Result.Success:
        return
    
    object_list = Rhino.Collections.TransformObjectList()
    object_list.AddObjects(go, True)
    
    dir = Rhino.Geometry.Vector3d(5.0, 0.0, 0.0)
    xform = Rhino.Geometry.Transform.Translation(dir)
    
    for grip in object_list.GripArray():
        grip.Move(xform)
        
    for owner in object_list.GripOwnerArray():
        sc.doc.Objects.GripUpdate(owner, True)
        
    sc.doc.Views.Redraw()
    
if __name__=="__main__":
    test_move_grips()

Does this help?

– Dale

1 Like

Bumping this again, are there ways to create and reference cages and their grips directly in Rhinocommon for Rhino 7? I can’t find them under Geometry.