Grasshopper

algorithmic modeling for Rhino

Hi,

How to change this python script, that every time I change base - point, the script updates itself?

Is it possible to do this without grasshopper timer, using Rhino EditPythonScript

Python script:

#############

import rhinoscriptsyntax as rs

def vectorField():
    cloud_id = rs.GetObject("Input pointcloud", 2, True, True)
    if cloud_id is None: return
    
    listpoints = rs.PointCloudPoints(cloud_id)
    base_point = rs.GetPoint("Vector field base point")
    if base_point is None: return
    
    for point in listpoints:
        vecbase = rs.VectorCreate(point, base_point)
        vecdir = rs.VectorCrossProduct(vecbase, (0,0,1) )
        
        if vecdir:
            vecdir = rs.VectorUnitize(vecdir)
            vecdir = rs.VectorScale(vecdir, 2.0)
            AddVector(vecdir, point)

def AddVector(vecdir, point):
    tip_point = rs.PointAdd(point, vecdir)
    line = rs.AddLine(point, tip_point)
    if line: return rs.CurveArrows(line,2)

vectorField()

#############

Below screenshot is attached

Views: 643

Attachments:

Replies to This Discussion

Hi Petras

are you looking for something similar to this?

The only main difference from your script is that, unfortunately, arrowheads are not currently supported in Grasshopper, but we could apply them once we bake the lines into Rhino. Or we could draw them with tiny surfaces, lines or meshes.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Attachments:

Thanks, that was what I am looking for:)

But is that possible in python, without using grasshopper?

I mean, executing the code not once but constantly updating, like in processing?

It is "possible", but it is much much easier using Grasshopper and Python together. One way that I can think of, would be handling a display draw event from the use of a GetPoint instance on the commandline. But really,... why do you need to make that complicated?

If you absolutely have to, the right place to ask would be the Rhino forum, scripting category.

I hope this helps,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service