Grasshopper

algorithmic modeling for Rhino

I'm new to python. Then get some trouble when writing following

How to get a Plane's Yaxis in rhinoscriptsyntax?(those red thing~)

import Rhino.Geometry as rg
import rhinoscriptsyntax as rs
import scriptcontext as sc
import math

def CrvToVec(crv):
    spt=rs.CurveStartPoint(crv)
    ept=rs.CurveEndPoint(crv)
    vec=rs.VectorCreate(spt,ept)
    return vec

def TestAngle(crv1,crv2):
    vec1=CrvToVec(crv1)
    vec2=CrvToVec(crv2)
    ang=rs.VectorAngle(vec1,vec2)
    if ang>80:
        ang=90
    if ang<10:
        ang=0    
    return ang

Ang=[]
for i in range(0,len(x)-1):
    Ang.append(TestAngle(x[i],x[i+1]))

def DrawLine(crv1,crv2,ang):
    pt1=rs.CurveEndPoint(crv1)
    len=rs.CurveLength(crv2)
    pln=rs.PlaneFromPoints(pt1,rs.CurveStartPoint(crv1),rs.CurveStartPoint(crv2))
    Yaxis=????(how to get pln's Yaixs vector?)
    uvec=rs.VectorUnitize(Yaxis)
    svec=rs.VectorScale(uvec,len)
    pt2=rs.PointAdd(pt1,vec)
    line=rs.AddLine(pt1,pt2)
    return line

Line=[]
Line.append(x[0])
for i in range(0,len(x)-1):
    x[i+1]=DrawLine(x[i],x[i+1],Ang[i])
    Line.append(x[i+1])

a=Line
b=Ang

Views: 453

Replies to This Discussion

Hi Archy! You should be able to use pln.YAxis to find Yaxis.

Thank you very much~Solved~

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service