RhinoScriptSyntax のAPIに矢印の形をしたオブジェクトを作成する機能はない\\
(CurveArrows は、曲線の描画スタイルを変更するもの)
次の関数を使用することで、円柱と円錐を組み合わせた立体的な矢印を生成できる
# sp: 始点座標
# ep: 終点座標
# arrowHeadRatio: 線に対する先端円錐の高さの割合
# arrowHeadBaseR: 矢印先端円錐の底面半径
# arrowPipeR: 線の太さ半径
def makeArrow(sp, ep, arrowHeadRatio=0.3, arrowPipeR=5, arrowHeadBaseR=10):
objs = []
arrowVec = rs.VectorSubtract(ep, sp)
coneBasePoint = rs.VectorScale(arrowVec, 1.0 - arrowHeadRatio)
coneBasePoint = rs.VectorAdd(sp, coneBasePoint)
# make pipe
arrowPipe = rs.AddCylinder(sp, coneBasePoint, arrowPipeR)
objs.append(arrowPipe)
# make head
cone = rs.AddCone(coneBasePoint, ep, arrowHeadBaseR)
objs.append(cone)
return objs
==== サンプルコード1 ====
1本の矢印を生成
import rhinoscriptsyntax as rs
a = []
def makeArrow(sp, ep, arrowHeadRatio=0.3, arrowPipeR=5, arrowHeadBaseR=10):
objs = []
arrowVec = rs.VectorSubtract(ep, sp)
coneBasePoint = rs.VectorScale(arrowVec, 1.0 - arrowHeadRatio)
coneBasePoint = rs.VectorAdd(sp, coneBasePoint)
# make pipe
arrowPipe = rs.AddCylinder(sp, coneBasePoint, arrowPipeR)
objs.append(arrowPipe)
# make head
cone = rs.AddCone(coneBasePoint, ep, arrowHeadBaseR)
objs.append(cone)
return objs
a.extend(makeArrow([0,0,0], [100,100,100]))
実行結果
{{:arrow.png?direct|}}