Quantcast
Channel: Scripting - McNeel Forum
Viewing all 4174 articles
Browse latest View live

Parallel Foreach Data STructure

$
0
0

@timothytai wrote:

Hi all,

I’m testing a Parallel Foreach C# node to test for curve containment. Basically extracting the discontinuity of each polyline curve and test if at least one point lies within the boundary curve. This works well while the data set is small, but becomes quite slow when a large number of curves are tested.

As I try to write a parallel process, it seems to work, but the order of these discontinuities get messed up so the resulting curves (organized as one curve per branch) are not connected properly. I could obviously cull the initial input with the test output without reconstructing the curves with points, but would still love to know how I would’ve done this for future/other data sets.

I understand that somehow it is related to how parallel processes need to be thread-safe, but am unsure how to fix this…I read through the post below but I believe the difference is that my data structure is a tree with branches containing multiple values themselves:

Attaching the file and below are screenshots of when the parallel boolean is set to False, and then True, and the gh setup with the code in the C# node. Any help is much appreciated!

containment_par_v3_test.gh (71.9 KB)



Posts: 1

Participants: 1

Read full topic


CurveBooleanDifference Inconsistency

$
0
0

@shanew06 wrote:

Hi All,

I’ve been coming across a problem in one of my scripts and narrowed it down to the CurveBooleanDifference function in Rhino 5 (VBS).

I have a sample file and script to show the problem so would appreciate being able to send it to someone to investigate. Thanks.

Regards,

Shane.

Posts: 12

Participants: 2

Read full topic

Slider expressions extract with python?

$
0
0

@Jonas-Blazinskas wrote:

Hey guys how would one get the sliders expression from the given slider?

I barely understand python so a working example would be nice, I personally haven’t found documentation on how to extract this exact parameter. Thank you for your help in advance!

Regards,

Jonas Blazinskas

Posts: 6

Participants: 2

Read full topic

Eto Slider Values don't update dynamically with python

$
0
0

@raylee14 wrote:

Hi everyone,
I am learning the python eto. I set the default value as 3. However, I found three problems. You may check the attached figure

  1. the line doesn’t change when i am sliding the slider value dynamically. I need to close the window first to make changes
  2. the current value of the slider is always the default value, not the value i set last time.
  3. I cannot adjust the viewport on rhino when the window is on.

Also, I am new to python eto. I found a little resource to learn online, could anyone give some suggestion in learning eto?

thanks in advance

Posts: 3

Participants: 2

Read full topic

Group curves

$
0
0

@vikthor wrote:

Hi, sorry to bother you, I found this script which is great thank you very much, but I want to group the curves and I can’t get it to work

‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
’ DivideCurveDashed.rvb – October 2010
’ If this code works, it was written by Dale Fugier.
’ If not, I don’t know who wrote it.
’ Works with Rhino 4.0 and 5.0.
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’

Option Explicit

’ Divides a curve into “dashed” segments
Call DivideCurveDashed
Sub DivideCurveDashed
Dim arrSel,arrObjs,strGroup,msg,strBC
Dim curve, slength, dlength
Dim i, length, pt, t, dom, results

curve = Rhino.GetObject(“Select curve to divide”, 4, True)
If IsNull(curve) Then Exit Sub

slength = Rhino.GetReal(“Segment length”, 1.0)
If IsNull(slength) Then Exit Sub
If (slength <= 0) Then Exit Sub

dlength = Rhino.GetReal(“Dash length”, 1.0)
If IsNull(dlength) Then Exit Sub
If (dlength <= 0) Then Exit Sub

Call Rhino.EnableRedraw(False)
i = 0

Do

  If (i Mod 2 = 0) Then
  	length = slength
  Else
  	length = dlength
  End If

  pt = Rhino.CurveArcLengthPoint(curve, length)
  If IsNull(pt) Then Exit Do

  t = Rhino.CurveClosestPoint(curve, pt)

  If (i Mod 2 = 0) Then
  	results = Rhino.SplitCurve(curve, t, True)
  	curve = results(1)
  Else
  	dom = Rhino.CurveDomain(curve)
  	curve = Rhino.TrimCurve(curve, Array(t, dom(1)), True)
  End If

  i = i + 1

Loop While True

Call Rhino.EnableRedraw(True)
Call Rhino.Command("_SelLast")
arrObjs = Rhino.SelectedObjects

If IsArray(arrObjs) Then
strGroup = Rhino.AddGroup
Call Rhino.AddObjectsToGroup(arrObjs, strGroup)
Call Rhino.AddObjectToGroup(strBC, strGroup)
Call Rhino.ObjectsByGroup(strGroup, True)
If IsArray(arrSel) Then Call Rhino.SelectObjects(arrSel)
End If

End Sub

original link

Posts: 5

Participants: 2

Read full topic

Python Script Editor not opening

$
0
0

@ingemar wrote:

I just installed Python 0.6.0.3 on Rhino 6 and GH 1.0.000.7
But Python Script Editor does not open when hitting the node. Is there a version issue?
Newbie grateful for advice.
Ingemar

Posts: 1

Participants: 1

Read full topic

How to rotate object

$
0
0

@xiix.xoox wrote:

i use:rs.RotateObject(obj,starpointCrv,corner) to rotated the object but not true.
I need it rotated round the curve with corner+= 90.
How get plane to rotate it.

Posts: 5

Participants: 2

Read full topic

ETO Forms Group Box

$
0
0

@eric.bunn wrote:

Hi,

I’m trying to contruct a form in Rhino 6 (python) and going through the examples here:

I get an error when I try to put in a group box. I’m using the following code:

Create a group box

    self.m_groupbox = forms.GroupBox(Text = 'Groupbox')
    self.m_groupbox.Padding = drawing.Padding(5)
    
    grouplayout = forms.DynamicLayout()
    grouplayout.Spacing = Size(3, 3)

Here is the error:

Message: global name ‘Size’ is not defined

Traceback:
line 26, in init, “C:\Users\bunner\OneDrive - Sealed Air Corporation\Computer\Desktop\Test User Form\Rhino ETO Example.py”
line 132, in RequestRoomNumber, “C:\Users\bunner\OneDrive - Sealed Air Corporation\Computer\Desktop\Test User Form\Rhino ETO Example.py”
line 145, in , “C:\Users\bunner\OneDrive - Sealed Air Corporation\Computer\Desktop\Test User Form\Rhino ETO Example.py”

It doesn’t appear to like the line grouplayout.Spacing = Size(3, 3)

Thanks for the help.

Eric

Posts: 5

Participants: 3

Read full topic


Run function after combo box value change in ETO Form

$
0
0

@eric.bunn wrote:

Hi,

How does one run a function immediately following a user selection in a combo box? (Click Event or Update Event?)

Eric

Posts: 6

Participants: 2

Read full topic

Update ironpython in rhino5

$
0
0

@dai_kandeel wrote:

Hello I am trying to use an updated version of ironpython in rhino5 to be able to use some commands in rhino vault, but despite adding the path of the new version and moving it to top as described in the paper, it is still shown that the old version is used !

Posts: 1

Participants: 1

Read full topic

Quick mirror command

$
0
0

@Mikey wrote:

Hi, is it possible to mirror selected geometry pieces by X-axis for example and make it historically associative? Routine operation it is so would be great to have a button without any options. Thank you :slight_smile:

Posts: 3

Participants: 2

Read full topic

Extrude curve into a surface by scripting in Python

$
0
0

@cavasct wrote:

Hi! How could I convert an extrude curve into a surface in order to offset the new surface into a solid?
Thank you in advance!

Posts: 3

Participants: 2

Read full topic

GH Python : simple gravity problem

$
0
0

@kukarteknis wrote:

Dear All,

I have been following a tutorial from Jake Hebbert’s channel on Youtube and trying to make a simulation of a bouncing ball with friction and gravity constraint but the animation (simulation) was moving very slow and I have a syntax error to define “normal”. I hope anyone can help me. Thank yousimple gravity and fraction.gh|attachment (15.3 KB)

Posts: 1

Participants: 1

Read full topic

Disable or enable control in ETO form

$
0
0

@eric.bunn wrote:

How would one disable or enable a control on an ETO form? For example based on the state of a checkbox a control would be enabled or disabled for operator input.

Eric

Posts: 3

Participants: 2

Read full topic

Bad GUID: Message: 00000000-0000-0000-0000-000000000000 does not exist in ObjectTable

$
0
0

@eric.bunn wrote:

Hi,

I am coming up with this error when running the line of code pasted below: Message: 00000000-0000-0000-0000-000000000000 does not exist in ObjectTable

I am assuming this is some type of bad object? Is there error checking I can employ for this?

Here is the line of code:
id_c = Rhino.RhinoDoc.ActiveDoc.Objects.Add(obj_c)

I’m running Rhino 5 using python.

Thanks,

Eric

Posts: 3

Participants: 2

Read full topic


Change Text Block Annotation Style

$
0
0

@miano wrote:

How would one change the annotation style for all the selected text blocks in a file?

Have found an example of how to do it with dimensions but it does not work with text blocks.

Posts: 3

Participants: 2

Read full topic

Python - Recursion error. Fractal does not want to multiply

$
0
0

@lelesong.gothenburg wrote:

Hello Everyone,

I am a python beginner and I am having hard time to make recursion working. I want to create rectangle fractal which will multiply itself as it goes smaller and smaller.

but for some reason it does not want to multiply itself. Can anybody give me an advise? Here is the code. Thank you for the help.

import rhinoscriptsyntax as rs
import math
import Rhino as r

Fractal1 =
pts =
Fractals =

def Fractal_split(rec,repetition,p):

explodedCurves = rs.ExplodeCurves(rec,False)
for curve in explodedCurves:
    parameter = rs.CurveParameter(curve,p)
    point_on_curve = rs.EvaluateCurve(curve, parameter)
    pts.append(point_on_curve)
A = pts[0]
B = pts[1]
C = pts[2]
D = pts[3]
Fractal1 = rs.AddPolyline([A,B,C,D,A])

if (repetition > 0):
    repetition -= 1
    Fractal_split(Fractal1,repetition,p)

else:
    Fractals.append(Fractal1)

Fractal_split(rec,repetition,p)

Posts: 2

Participants: 2

Read full topic

C# sort points along line

$
0
0

@daniel.c wrote:

Hello,

I’m writing C# script in grasshopper. I want to sort points along polyline and create new polyline that goes trough sorted points. I came up with following code:

    Point3d[] sort_pts= culled_pts;
    double[] angles = new double[sort_pts.Length];
    for (int i = 0; i < sort_pts.Length; i++)
    {
      angles[i] = Math.Atan2(sort_pts[i].Y, sort_pts[i].X);
    }
    Array.Sort(angles, sort_pts);
    List<Point3d> final_pts = new List<Point3d>(sort_pts);
    Polyline final_top_poly = new Polyline(final_pts);

The problem is, that if the points Y coordinates are all 0 it breaks and doesnt work. It works if X coordinates are 0 and the rest of combination of coordinates… Any ideas why?
I appreciate the help, thanks.

Dan.

Posts: 2

Participants: 2

Read full topic

Work in progress - Quick area sketching overview

$
0
0

@sonderskovmathias wrote:

Hi all,

I’m slowly picking up C# after a few years in Python-land.
One of the first scripts I decided to make is a quick GH component, that I’ll share with you guys.

It works quite well for my intent - it provides quick feedback on your areas when sketching.
I had a colleague who had a similar workflow as native GH components and in terms of speed it beat all of my python attempts, but finally I beat him with C# :wink:

But there’s a bug - sometimes when relinking geometry my rhino6 freezes and crashes - most times it doesn’t. I can’t seem to find any error in my code. I was hoping to pick up some feedback on that.

Ideas, should anyone feel like adding to it:

  • automaticly pick up geometry on sublayers to a parentlayer with an update button (or use Human).
  • color output surfaces based on which layer they are hosted by.

Areascript.3dm (8.4 MB) Areascript.gh (35.8 KB)

Posts: 5

Participants: 2

Read full topic

How to change each different colors for some loft surface

$
0
0

@hakuko.hryk wrote:

Hi,
I 'm a beginner of scripting in gh.
Just I astarted as practice by combining some example files.

I struggling how to change each different colors for some loft surface.

result sees I should change list to integer.
But loft surface is consist of list.
What should I next? thanks in advance.200413_loft col.gh (3.4 KB)

Posts: 1

Participants: 1

Read full topic

Viewing all 4174 articles
Browse latest View live


Latest Images