본문 바로가기
컴퓨터/기타 프로그램

라이노(Rhino)에서 같은 오브젝트 선택하는 방법 (Python 스크립트)

by 날아라키위새 2021. 6. 22.
반응형

라이노를 사용하다 보면 같은 오브젝트를 선택해야 하는 경우가 생긴다.

레이어 정리를 잘해놓았다면 문제없겠지만

그게 아니라면 눈물을 흘리며 한 땀 한 땀 선택하다 잘못 눌러 처음부터 다시 시작하곤 한다.

같은 객체를 쉽게 선택하는 파이썬 스크립트를 사용해보자. Python 짱짱맨!

라이노(Rhino)에서 같은 오브젝트 선택하는 방법 (Python 스크립트)

1. 일단 아래의 스크립트를 복사해놓는다.

! _-RunPythonScript (

import Rhino
# Get a reference to the document
doc = Rhino.RhinoDoc.ActiveDoc
# Get all the objects in the document
objects = doc.Objects
# Get all the selected objects
selectedObjects = [o for o in doc.Objects.GetSelectedObjects(False,False)]
# try to get the first selected item, if it fails print a message to the command line
try:
    firstSelected = selectedObjects[0]
    objects.UnselectAll()
except:
    print "Select an object and re-run command"

# get the area of the first selected item
try:
    targetArea = Rhino.Geometry.AreaMassProperties.Compute(firstSelected.Geometry).Area
except:
    "Unable to measure object area"

# set up a list to hold all the items we want to select
toSelect = []
# for every item in the rhino document, try to get its area and compare it to the target area
for rhObj in objects:
    try:
        area = Rhino.Geometry.AreaMassProperties.Compute(rhObj.Geometry).Area
        if abs(targetArea - area ) < 0.01:
            toSelect.append(rhObj)
    except:
        pass
# for each item in the "to select" list, select it
for item in toSelect:
    objects.Select(item.Id)
)

 

2. 상단의 툴 버튼 오른쪽 빈 공간을 오른쪽 클릭 후 New Button을 눌러준다.

라이노 같은 오브젝트 선택하는 방법 (파이썬 스크립트)

3. Text only 체크한 후 Text에는 버튼에 사용할 이름을 적어준다. 

4. Command 아래 칸에 위에서 복사한 Python 스크립트를 붙여 넣고 OK 버튼을 눌러준다.

라이노 같은 오브젝트 선택하는 방법 (파이썬 스크립트)

5. 선택하고 싶은 오브젝트를 클릭하고 상단에 만들어진 버튼(select same)을 눌러주면 끝.

라이노 같은 오브젝트 선택하는 방법 (파이썬 스크립트)

컴퓨터 사양에 따라 라이노가 멈출 수 있으니 꼭 파일을 저장하고 해 보도록 하자.

반응형

댓글