Hi.
I have a question. How can I select a curve object and then find objects like it?
There is no automatic function in Rhino to do this. If you think you will need to do this later, the best is to give names to your objects or create them as blocks before multiplying your copies.
For simple objects like these, it might not be too hard to find them afterward, but there is some work involved. You need to first find a set of criteria that makes all of the copies of this object unique so they can be distinguished from all other objects. Then start testing all objects with the criteria…
For example:
Is it a polyline
Is it closed
Does it have 4 sides
Does it have the same area
Do all four sides have the same lengths
Are all the internal angles the same
etc…
oh. Really complicated. Hihi I also do not know which criterion is correct.
You can test run the script
Yep. Rhino does not have the capacity to find exact (or near-exact) copies of objects once they have been moved from the original - unless they are ‘marked’ in some way as instances of the original - via object name, using blocks or something similar. Once the horses are out of the barn without that, there is no easy way to round them up again.
I think the script compares. These 2 criteria are also 99% relative. hihi
- The length of the polyline
- Area
That can narrow it down a lot, but it won’t catch things like mirrored images or Tetris-like piece equivalents.
I think there is no need to search for the mirror object. it will be a new object. The script is great if it does
But anyway, if you really want to go with that here is a sample script:
import rhinoscriptsyntax as rs
def SelSameAreaLengthCrv():
base_crvID=rs.GetObject("Select curve to match",4,preselect=True)
if not base_crvID: return
all_crvIDs=rs.ObjectsByType(4,state=1)
if len(all_crvIDs)<2: return
target_len=rs.CurveLength(base_crvID)
area=rs.CurveArea(base_crvID)
if not target_len or not area: return
target_area=area[0]
tol=rs.UnitAbsoluteTolerance()
match=[]
for crvID in all_crvIDs:
test_len=rs.CurveLength(crvID)
if abs(test_len-target_len)<tol:
test_area=rs.CurveArea(crvID)
if test_area and test_area[0]:
if abs(test_area[0]-target_area)<tol:
match.append(crvID)
if match: rs.SelectObjects(match)
if len(match)==1: rs.UnselectObject(base_crvID)
print "Found {} matching curves".format(len(match)-1)
SelSameAreaLengthCrv()
great. Thank you. . I think it was 99%. Hi