rvb Move surface grips

rvb animation snippet example

This script shows how to move object grips with Rhinoscript.

Option Explicit

'Script written by Adolfo Nadal

'Script by archiologics · www.archiologics.com

Call Main()

Sub Main()

Dim strObject, arrGrips

strObject = Rhino.GetObject("Select surface", 8)

If Not IsNull(strObject) Then

Rhino.EnableObjectGrips strObject

Dim intCount, i

intCount = Rhino.ObjectGripCount(strObject)

For i = 0 To intCount

Rhino.SelectObjectGrip strObject, i

Next

arrGrips = Rhino.SelectedObjectGrips(strObject) 

' Process each grip    

Dim grip_idx, grip_pt, new_pt, uv

Dim normal_pts, normal, normal_scaled, distance

distance = 0.1

For Each grip_idx In arrGrips

' Get the grip's location

grip_pt = Rhino.ObjectGripLocation(strObject, grip_idx)

new_pt = grip_pt

new_pt(0) = new_pt(0)

new_pt(1) = new_pt(1)

new_pt(2) = new_pt(2) + 10

' Update the grip location

Rhino.ObjectGripLocation strObject, grip_idx, new_pt

Next

End If

End Sub

Function VectorCreate(p1, p2)

VectorCreate = Null

If Not IsArray(p1) Or (UBound(p1) <> 2) Then Exit Function

If Not IsArray(p2) Or (UBound(p2) <> 2) Then Exit Function

VectorCreate =  Array(p2(0) - p1(0), p2(1) - p1(1), p2(2) - p1(2))

End Function

 ' Scale a 3D vector

Function VectorScale(v, d)

VectorScale = Null

If Not IsArray(v) Or (UBound(v) <> 2) Then Exit Function

If Not IsNumeric(d) Then Exit Function

VectorScale = Array(v(0) * d, v(1) * d, v(2) * d)

End Function

 ' Adds a 3D vector to a 3D point

Function PointAddVector(p, v)

PointAddVector = Null

If Not IsArray(p) Or (UBound(p) <> 2) Then Exit Function

If Not IsArray(v) Or (UBound(v) <> 2) Then Exit Function

PointAddVector = Array(p(0) + v(0), p(1) + v(1), p(2) + v(2))

End Function

 

Search Site




archi·o·logics survey

I am interested in: