루비 왕초보 질문[도와주세요]

조회수 369회

This one-liner pasted into the Ruby Console +[enter] might work.

t=inputbox(['Find Text: '],[''],'');if(t);m=Sketchup.active_model;s=m.selection;s.clear;m.active_entities.grep(Sketchup::Text).select{|e|e.text=~/#{t[0]}/}.each{|e|s.add(e)};Sketchup.send_action('viewZoomToSelection:');end

In the dialog type the search string.

It uses regex matching so a few tips… It’s case-sensitive so use [Cc]at to find both matches [Cat, catalog]. Use [CcMm]at to find word matches [Cat, cat, Mat, mat, material]. Or M[ae]t etc fro [Material, Metal]… Note that you’ll need to escape ‘slashes’ as \ and \/ - and also place some characters inside [] - like , $ . and so on… otherwise a sting like 1.2 will match several possibilities, like 1.2, 122, 1a2 etc, but 1[.]2 will match only 1.2 To find all text starting with a lower-case letter use a-z [cat, mat, hat], to find all text ending with say ‘cm’ use cm$ [min. 12cm, 34cm, max. 39cm] etc…

All Text in the current active context is searched for a match. Any matching Text entities are highlighted. The Zoom is set to that Selection…


루비 코드질문해서 받은 답변인데

샘이 저기 코드 안에 #은 왜 넣은 걸까요?

이해가 안됩니다

  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)