Grasshopper 上で ReduceMesh

grasshopper 上で、ReduceMesh を行う。

ghPython のコードは冗長に見えるが、フォーラムによると、RhinoSDK の仕様的に、 RhinoApp、RhinoDoc を噛ませる必要とか書いてあるのでたぶんそういうもの。

import Rhino.RhinoApp as ra
import Rhino.RhinoDoc as rd

doc = rd.ActiveDoc;

if bool == True:
    print "Success !!"
    print "reduced by " + str(P) + " percent"

    if M is not None:
        meshObj = doc.Objects.AddMesh(M)
        doc.Objects.UnselectAll()
        doc.Objects.Select(meshObj)
        ra.RunScript("_-ReduceMesh _ReductionPercentage %s _Enter" %P ,False)
        mObj = doc.Objects.GetSelectedObjects(False,False)
        geomOut = []
        for m in mObj:
            geomOut.Add(m.Geometry)
        doc.Objects.Delete(meshObj,True)
        a = geomOut

else:
    print "NA"
    a = M


f:id:ysok_na:20180312143114j:plain


・-・-・-・-・-・


使い方

Toggle を False に。

target mesh を右クリック。Set mesh を選んで、Rhino上の meshを選択。

スライダーで削減したい割合を指定。

Toggle を True にすると削減が始まる。

良ければ、 Bake

・-・-・-・-・-・

参考にしたのはこれ→
www.grasshopper3d.com


このままだと、ghPython コンポーネントが常時走り出して、かなり不便なので、BoolToggle を付けた。

卒制のときにここのサンプル落としてきて使おうとしたときに、そのとき作ってた Mesh が重い + Toggle を自分で付けることを思いつかなくて、ただの自動フリーズスクリプトみたいになってたので改良。(180312)

・-・-・-・-・-・

僕の手元の実行環境は、

windows7 (bootcamp)
Rhinoceros5 (Win)
Grasshopper (0.9.0076)
ghPython (0.6.0.3)
ghPython はここから→
www.food4rhino.com





終わり



.