Information

RhinoScript

RhinoScript is a scripting tool based on Microsoft's VBScript language. With RhinoScript, you can quickly add functionality to Rhino, or automate repetitive tasks.

Website: http://wiki.mcneel.com/developer/rhinoscript
Members: 170
Latest Activity: Mar 6

Discussions

rs.OffsetCurveOnSurface() doesn't work the same as Rhino.OffsetCurveOnSurface()

While Rhinoscript method would offset the curve and extend it to the edges, python rs method would NOT.
Ok, fine, let me just run rs.ExtendCurve(crv, 2, 2, [srf]) with the surface as a border. Nope, some random curves would only extend to the border of the surface on one random end. So I have to literally run rs.ExtendCurve(crv, 2, 2, [srf]) again. Why is it so bad with python methods?..

test0.3dm (48.2 KB)

test.3dm (131.6 KB)

1 post - 1 participant

Read full topic

Cannot disable redraw in Rhino 6

Hi, I have a script that disables redraw for speed while it creates geometry, then enables it again afterwards:

import rhinoscriptsyntax as rs
rs.EnableRedraw(False)
…do stuff…
rs.EnableRedraw(True)

In rhino 5 it works as expected.
However when I run the same script in rhino 6 I can see the geometry being created in front of me on screen (and it takes minutes to complete, as opposed to seconds in rhino 5) - redraw is not disabled.

Is there something I’m not aware of here? Does redraw() behave differently in rhino 6 than it does in rhino 5?

In case it’s relevant, here is the OpenGL info from options in rhino 5:

And in rhino 6:

10 posts - 2 participants

Read full topic

How to save an image from ETO?

Hi @dale

Do you know how I save out an image from the ETO?
I have a script that makes a sunstudy, but I could not figure out how to save that to a JPG or PNG.

It’s based on stuff from here :slight_smile:

github.com

mcneel/rhino-developer-samples/blob/6/rhinopython/SampleEtoViewCaptureDialog.py

################################################################################# SampleEtoViewCaptureDialog.py# Copyright (c) 2017 Robert McNeel & Associates.
# See License.md in the root of this repository for details.
################################################################################
# Imports
import Rhino
import Rhino.UI
import Eto
import scriptcontext
import System
import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms

################################################################################
# SampleEtoViewCaptureDialog dialog class
################################################################################
class SampleEtoViewCaptureDialog(Eto.Forms.Dialog[bool]):
    
This file has been truncated. show original

Here’s what I do: I grab the view and alter the colors:

3 posts - 2 participants

Read full topic

Undo in Rhinoscript

Is there a Rhinoscript version of Python’s RhinoDoc.BeginUndoRecord and RhinoDoc.EndUndoRecord commands?

2 posts - 2 participants

Read full topic

Help generating growth algorithm from multiple points

Hi, I am new to python (started last month for class). I am unsure of how to combine my scripts together. I am trying to reproduce a growth algorithm from the points generated from my divided surface, but I am not sure how to use a for loop to implement multiple points into the next step.

To explain further:


^ I want to grow these spheres


^ Out of each point I generated here


^Those points came from this surface I made

I am just unsure how to combine it together without it giving me an error. I got it to work with one point, just not multiple.

This is the script I have so far:

“”"
How to generate growth from the points of a surface
“”"

import rhinoscriptsyntax as rs
import random

#-------------------------------------------------

#Selects the already created base surface from rhino

BASE = rs.GetObject(“Pick any object”)

if BASE:
print "Object identifier: ", BASE

#-------------------------------------------------

#Determines the number of divisions on the base surface

number_divisions = 15

def DivideSurface(BASE, divisions):
u_domain = rs.SurfaceDomain(BASE, 0) #Gets the original u-direction domain of the base surface
v_domain = rs.SurfaceDomain(BASE, 1) #Gets the original v-direction domain of the base surface
for i in range(divisions+1):
u = u_domain[0] + (u_domain[1]-u_domain[0])*i/divisions #Divides the original u-direction domain of the base surface
for j in range(divisions+1):
v = v_domain[0] + (v_domain[1]-v_domain[0])*j/divisions #Divides the original v-direction domain of the base surface
point = rs.EvaluateSurface(BASE,u,v)
rs.AddPoint(point) #Adds the points generated from the divisions onto the base surface
rs.AddSphere(point, 2) #Adds spheres onto the points

DivideSurface(BASE, number_divisions) ##Generates points based on the number of divisions and adds spheres onto the points

#-------------------------------------------------

rs.DeleteObject(BASE)

#-------------------------------------------------

from Rhino import *
from Rhino.DocObjects import *
from Rhino.Commands import *
from Rhino.Input import *
from Rhino.Input.Custom import *
from scriptcontext import doc

#selects multiple points that already exists
#using the RhinoScript syntax
point_ids = rs.GetObjects(“Select point”, rs.filter.point)
for p_id in point_ids:
print “point id: {0}”.format(p_id)

#-------------------------------------------------

#Simple Growth script

import random #This module implements pseudo-random number generators for various distributions

def placePt(x_range,y_range,z_range):
x = random.uniform(0,x_range) #Random uniform gets a random number in the range specified
y = random.uniform(0,y_range)
z = random.uniform(0,z_range)
pt = [x,y,z] #Creates a point based on the random uniform generator
return pt

rs.EnableRedraw(False)

ptZero = [50,50,50] #Starting point where growth generates from
pts = #EmptyList
pts.append(ptZero) #Adds point zero to the list
sphereZero = rs.AddSphere(ptZero, .5) #Adds a sphere to the starting point

for i in range(0,1000): #Integers within given start and stop number
pt = rs.AddPoint(placePt(100,100,100)) #Runs the point into a randomizer through the range specified and adds it into rhino with the new coordinates
index = rs.PointArrayClosestPoint(pts,pt) #Point array finds the closest point to the set of points and will be used to create a vector
cp = pts[index]
vect = rs.VectorCreate(cp,pt) #Creates a vector from the closest point to the starting point
unitVect = rs.VectorUnitize(vect) #Unitize vector keeps the same direction but changes the length to 1 unit
subVect = vect - unitVect #Subtracts the original vector length with the new vector length to get a shorter vector
newPt = rs.MoveObject(pt,subVect) #Uses the subtracted vector result to move point and create a new point
rs.AddSphere(newPt,.5) #Adds a sphere to the newly created point
pts.append(newPt) #Adds new point to the list

rs.Redraw()

1 post - 1 participant

Read full topic

 

Members (170)

 
 
 

Translate

© 2020   Created by McNeel Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service