top of page
Writer's pictureDavid Mans

Visualize Points

šŸ’» Rhino 5

šŸ”¼ Rhino Script

šŸ› ļø Visual Basic

Ā 

This Rhino Script presents a series of options for the visualization of points, relative to graphics output. Once points are selected the user can then select to overlay the points with either a circle curve, cross curve, coordinate anchor curve, spherical surface, or cubical polysurface. Once the output type is selected a series of orientation options are made available, either using the world coordinate plane, the camera plane, current construction plane, or a plane perpendicular to a user-specified point.

Ā 
Option Explicit
'Script written by <David Mans>
'Script copyrighted by <Neoarchaic Studio>
'Script version Wednesday, September 16, 2009 4:56:53 PM
 
Call Main()
Sub Main()
    Dim arrPtset, arrMode, arrOrient
    arrPtset = Rhino.GetObjects("Select Points to Visualize", 1,, True, False)
    If isNull(arrPtset) Then Exit Sub
     
    arrMode = Rhino.GetString("Select Visualization Mode", "Box", array("Circle", "Sphere", "Cross", "Coordinate_System", "Box"))
    If isNull(arrMode) Then Exit Sub
    arrOrient = Rhino.GetString("Select Object Orientation", "World", array("World", "Active", "Point", "Camera"))
    If isNull(arrOrient) Then Exit Sub
         
    'Optional Inputs
    Dim arrUserPt, dblRadius, arrCS
    If arrOrient = "Point" Then
        arrUserPt = Rhino.GetPoint("Select Point to Orient Objects Towards", array(0, 0, 0))
    ElseIf arrOrient = "Camera" Then
        arrUserPt = Rhino.ViewCamera()
    End If
    If arrOrient = "World" Then
        arrCS = Rhino.GetString("World Coordinate System", "XY", array("XY", "YZ", "ZX"))
    End If
     
    dblRadius = Rhino.GetReal("Radius", 1)
    If isNull(dblRadius) Then Exit Sub
     
    'Evalute for Each Point
    Dim i, j, arrPt, arrPln, tpt(), v(2), x, y, z
     
    If arrMode = "Box" Then
        ReDim tPt(7)
        x = array(1, -1, -1, 1, 1, -1, -1, 1)
        y = array(1, 1, -1, -1, 1, 1, -1, -1)
        z = array(-1, -1, -1, -1, 1, 1, 1, 1)
    ElseIf arrMode = "Cross" Then
        ReDim tPt(5)
        x = array(1, -1, 0, 0, 0, 0)
        y = array(0, 0, 1, -1, 0, 0)
        z = array(0, 0, 0, 0, 1, -1)
    ElseIf arrMode = "Coordinate_System" Then
        ReDim tPt(5)
        x = array(-1, 0, 0, 0, 0, 0)
        y = array(0, 0, -1, 0, 0, 0)
        z = array(0, 0, 0, 0, -1, 0)
    End If
    Call Rhino.EnableRedraw(False)
    For i = 0 To uBound(arrPtset) Step 1
        arrPt = Rhino.PointCoordinates(arrPtset(i))
        'Set up orientation options
        If arrOrient = "World" Then
            If arrCS = "XY" Then
                arrPln = Rhino.MovePlane(Rhino.WorldXYPlane(), arrPt)
            ElseIf arrCS = "YZ" Then
                arrPln = Rhino.MovePlane(Rhino.WorldYZPlane(), arrPt)
            ElseIf arrCS = "ZX" Then
                arrPln = Rhino.MovePlane(Rhino.WorldZXPlane(), arrPt)
            End If
        ElseIf arrOrient = "Active" Then
            arrPln = Rhino.ViewCPlane()
        ElseIf arrOrient = "Point" Then
            arrPln = Rhino.PlaneFromNormal(arrPt, Rhino.VectorCreate(arrPt, arrUserPt))
        ElseIf arrOrient = "Camera" Then
            arrPln = Rhino.PlaneFromNormal(arrPt, Rhino.VectorCreate(arrPt, arrUserPt))
        End If
         
        'Execute Visualization Functions/ Geometry
        If arrMode = "Circle" Then
            Call Rhino.AddCircle(arrPln, dblRadius)
        ElseIf arrMode = "Sphere" Then
            Call Rhino.AddSphere(arrPt, dblRadius)
        ElseIf arrMode = "Box" Then
            For j = 0 To 7 Step 1
                tPt(j) = evaluatePlane(arrPln, array(dblRadius * x(j), dblRadius * y(j), dblRadius * z(j)))
            Next
            Call Rhino.AddBox(tPt)
        ElseIf arrMode = "Cross" Or arrMode = "Coordinate_System" Then
            For j = 0 To 4 Step 2
                tPt(j) = evaluatePlane(arrPln, array(dblRadius * x(j), dblRadius * y(j), dblRadius * z(j)))
                tPt(j + 1) = evaluatePlane(arrPln, array(dblRadius * x(j + 1), dblRadius * y(j + 1), dblRadius * z(j + 1)))
                Call Rhino.AddLine(tPt(j), tPt(j + 1))
            Next
        End If
    Next
     
    Call Rhino.EnableRedraw(True)
End Sub
Function evaluatePlane(arrPlane, arrPoint)
    evaluatePlane = Null
    Dim i, arrPt
    arrPt = arrPlane(0)
    For i = 0 To 2 Step 1
        arrPt = Rhino.PointAdd(arrPt, Rhino.VectorScale(Rhino.VectorUnitize(arrPlane(i + 1)), arrPoint(i)))
    Next
     
    evaluatePlane = arrPt
End Function
Ā 


13 views

Recent Posts

See All
bottom of page