Rhino.DocObjects copy problem

Dear all,

Could anybody help me about the problem of  "Rhino.DocObjects.ObjRef" duplicating? 
I want to use objRef (Dim objRef as Rhino.DocObjects.ObjRef) to duplicate from go.object(i),
but it is seem failure. And It is correct in the following code, but it is not what I want.
objRef(i) = go.Object(i)

All I want is objRef(i) = go.Object(i).Duplicate()

Could anybody tell me how to do? 

Best Regards,
Jerry

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Shared trim_surface_entity_num As Integer
    Public Shared trim_surface_entity(1) As Rhino.Geometry.Brep
    Public Shared trim_surface_entity_att(1) As Rhino.DocObjects.ObjectAttributes
    Public Shared objRef(1) As Rhino.DocObjects.ObjRef    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Dim go As New Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt("Select objects to group-" & tt)
    go.GetMultiple(1, 0)
    go.GroupSelect = True

    'Surface Select
    If II = 20 Then
        trim_surface_entity_num = go.ObjectCount
        ReDim objRef(go.ObjectCount)
        ReDim trim_surface_entity(go.ObjectCount)
        ReDim trim_surface_entity_att(go.ObjectCount)
        For i = 0 To go.ObjectCount - 1
            objRef(i) = go.Object(i)
            trim_surface_entity(i) = go.Object(i).Object.DuplicateGeometry()
            trim_surface_entity_att(i) = go.Object(i).Object.Attributes
        Next i
    End If

Hi Jerry,

Can you explain what you are trying to do and why? This way, we can provide you a correct solution. :wink:

– Dale

I think that I maybe already solve duplicating problem…see the following code

objRef(i).Object().GripsOn = True
            ro = objRef(i).Object.GetGrips
            For j = 0 To ro.Length - 1

                pt = ro(j).CurrentLocation
                x = pt.Item(0)
                y = pt.Item(1)
                z = pt.Item(2)
                '
                newx = ((x - sx_middle) * sx) + sx_middle
                newy = ((y - sy_middle) * sy) + sy_middle
                newz = ((z - sz_middle) * sz) + sz_middle
                '
                dx = newx - x
                dy = newy - y
                dz = newz - z
                testTransform = Rhino.Geometry.Transform.Translation(dx, dy, dz)
                ro(j).Move(testTransform)
            Next j
            '
            Att = objRef(i).Object.Attributes
            Att.LayerIndex = k_layer + before_layer
            docc.Objects.GripUpdate(objRef(i).Object, False)
            docc.Objects.ModifyAttributes(objRef(i).Object, Att, True)
            objRef(i).Object().GripsOn = False

But this code is seem unsteady, firstly when I move these grippoints, the screen appear
many untrim points, it will disappear after I press “esc” key. if I move many surfaces,
rhino will crush?

The following figures are my results, could you help me solve this problem?

Update…I find that run this program will crush, and these geometry entitys have one
polysurf, Why this happend? How to solve it?

Hi Jerry,

Can you post your geometry and complete source code to a command that allows me to repeat what you are doing?

Thanks,

– Dale