Select Duplicate Geometry in RhinoCommon


#1

Hi guys,

Is it anything in RhinoCommon allowing me to select duplicated objects just as SelDup command does?
Basically I would like to perform such a cleaning in every Block in the document but there are quite a lot of blocks to do it manually.

In addition would be nice to know how to delete a specific object type from the block.

Thanks.
Dmitriy


(Dale Fugier) #2

Hi Dmitriy,

The C++ function behind the SelDup command is RhinoCompareGeometry. If you have the Rhino C++ SDK, you can find the function in rhinoSdkUtilities.h. Note, the only function in RhinoCommon that uses this function, at this time, is Rhino.Geometry.Brep.IsDuplicate().

To redefine a block, you first need to get it’s definition - Rhino.DocObjects.InstanceDefinition. This object will give you the underlying geometry. Find what you want and remove it, and then modify the instance definition using InstanceDefinitionTable.ModifyGeometry. The document holds the instance definition table.

– Dale


#3

Thanks @dale,

I can see underlying geometry but cannot see how to delete it…

Dim iref As Rhino.DocObjects.InstanceObject = TryCast(rhObj, Rhino.DocObjects.InstanceObject)
If iref IsNot Nothing Then
    Dim idef = iref.InstanceDefinition
    If idef IsNot Nothing Then
       Dim rhino_objects As RhinoObject() = idef.GetObjects()
       '...
    End If
End If

#4

Hi,

Solution is found - so easy.
Just need to feed a new List of geometry into ModifyGeometry.

Thanks a lot!


#5

for Brep, there is 'brep.Duplicate() function.
but how about ray3d, point3d, vector3d etc?
for example.
Structure Smple
dim rys() as ray3d
dim something as integer
etc…
end structure
dim ryL as new list(of Smple)
dim copyryL list(of Smple)
copyryL=ryL
ryL.add( structure Smple data include A ray3d, B ray3d, etc …)
for i=0 to ryLcount-1
… function…may be simulation.
ryL(i) may be changed
next
after then,
I found 'copyryL ’ is also changed.
I tried many way to avoid it. but only found that I have to make a new list of sturcture and much more the ray3d and other data one by one which is in the Smple structure.
can not copy by this way " A=B "
To copy array in structure, somebody say that I have to copy one by one, but not for the rhino geometry data.
Is there any method to “copy” the data easily? not to “make” one…
Please…


(Dale Fugier) #6

A post was split to a new topic: Select duplicate hatches