Quantcast
Channel: Grasshopper Developer - McNeel Forum
Viewing all 3626 articles
Browse latest View live

Anemone to iterate through list?

$
0
0

@franeb_96 wrote:

Hi, I am trying to use anemone loops to iterate through a list and execute a function for each index.

This is a university coursework that tries to analize and recreate the stalled World Islands in Dubai. I need each point in the island cluster to find its closest “port” and output all those lines at once. The function inside the loop is what does that, and I wanted to repeat that as many times as there are points, but there seems to be something missing as it only runs once. The data outputted is correct in the sense that the number is always increasing by 1 up to 155, but that “new” number is not being passed on as a list index, which always stays as 0. Am I screwing up the connections? does the solution look totally different?

Posts: 5

Participants: 2

Read full topic


C# component event subscription bug

$
0
0

@archimax wrote:

I’ve noticed a very annoying event related bug in c# script component.
After closing and reopening a c# component with event subscriptions all the delegates are subscribed once again. I need to restart Rhino to make all delegates work as expected after each change in my code.

Here is an example:

private void RunScript(bool x, object y, ref object A)
  {
    GrasshopperDocument.SolutionStart -= PrintStart;
    GrasshopperDocument.SolutionStart += PrintStart;

    GrasshopperDocument.SolutionEnd -= PrintEnd;
    GrasshopperDocument.SolutionEnd += PrintEnd;
  }

  // <Custom additional code> 

  public void PrintStart(object sender, GH_SolutionEventArgs e)
  {
    RhinoApp.WriteLine("Before solution!");
  }

  public void PrintEnd(object sender, GH_SolutionEventArgs e)
  {
    RhinoApp.WriteLine("After solution!");
  }

You would expect to have

Before solution!
After solution!

in the Rhino command line after each solution is calculated. And it works exactly like that before you reopen c# script, add another empty line or edit your code somehow. Then boom:

Before solution!
Before solution!
After solution!
After solution!

Edit your code once again and get a triple result. And so on.
The only way to reset things to normal is to restart Rhino.

eventBug.gh (2.9 KB)

Posts: 2

Participants: 2

Read full topic

Python.Rhino.GH Bidimensional Array with Full print 1 empty print 0

$
0
0

@valentin.cocq wrote:

Hello !!

During this time at home I want to Learn/Use Python in Rhino/Grasshopper to create “Loop” like Life of Convey.

It’s my first time using Python I watched a lot of video on YouTube and course on Scribbs but I feel very dumb watching my Rhino.Python editing and trying to do a True/False test. I definitely need some help

If you guys have some time to share with me your knowledge I would appreciate it :slight_smile:

My final work / experimentation consist to create a “Grid” 50x50 filled by square 1x1 and them put predetermining square the grid automatically like the game of life.

At the moment I am trying to make the grid work and then put manually a square on it to see if the area outside the square “empty” are full of TextTag “0” and inside the square full of TextTag “1”

At the moment I just made the grid on Grasshopper and saw some other references like

Posts: 1

Participants: 1

Read full topic

Using Transform.ChangeBasis

Getting Emgu CV (OpenCV) to work in GHPython Guide

$
0
0

@vbl wrote:

Guide for getting Emgu CV to work in the GHPython component:

You want to do something with Computer Vision and Grasshopper?
Already Realised that OpenCV doesn’t work with IronPython?
Scrapped the forums and found that Emgu CV is an option?
Can’t figure out how to install the damn thing?

I feel for you because I’ve been there too. That’s why I made this guide!

Follow these 7 easy steps and you will be ready to detect faces (and other body parts) from the comfort of the GHPython component in Grasshopper:

Step0:
Turn on your Computer.

Step1:
Download the latest version of EmguCV from SourceForge (in my case it was 4.2.0).

Link for EmguCV download: https://sourceforge.net/projects/emgucv/files/

Step2:
Install EmguCV to “C:\Emgu”

Step3:
Create a python file called “EmguInit.py” and save it at “C:\Emgu\bin”.

The file should contain the following code:

import clr
clr.AddReferenceToFile("Emgu.CV.World.NetStandard.dll")
clr.AddReferenceToFile("Emgu.CV.UI.dll")
from Emgu.CV import *
from Emgu.CV.UI import *
from Emgu.CV.Structure import *
from System import *

Step4:
In Rhino add a Module Search path for python.
You can do this by typing in EditPythonScript in the command line. When the Rhino Python Editor opens, go to Tools --> Options and add “C:\Emgu\bin” to the search paths.

Step5:
Under “C:\Emgu\libs” you are going to find two folders “x64” and “x86”. Copy both of them to the “C:\Program Files\Rhino 6\System” folder.

Step6:
Restart Rhino.

After Rhino starts again you will be able to use Emgu CV from GHPython by importing EmguInit:

import EmguInit
from EmguInit import *

To use OpenCV methods you will need to utilise the Emgu CV “CvInvoke” class:

img = cv2.imread('test_2.png')OpenCV syntax

img = CvInvoke.Imread('test_2.png')Emgu CV syntax

You can find more information on EmguCV CvInvoke methods here:

http://www.emgu.com/wiki/files/4.2.0/document/html/bb544594-4bf7-5a11-594c-f143b226f1da.htm

Good luck in anything you are trying to do!

VBL

Posts: 1

Participants: 1

Read full topic

GH_GeometricGoo: ReferenceID cannot be set

$
0
0

@mingo1214 wrote:

Hi All,

I am trying to a custom GH type based on GH_GeometricGoo<Brep>.
One problem that I found its ReferenceID cannot be set, when I try to pick up a referenced Rhino object.

Here is my example code:

 public HBRoom(Rhino.DocObjects.ObjRef objRef): this(objRef.Brep())
 {
      this.ReferenceID = objRef.ObjectId;
 }

ReferenceID is always Guid.Empty.

Could you please let me know if I am missing anything?
Thanks,

cc @DavidRutten

Posts: 2

Participants: 2

Read full topic

Cutting out brep and brep projection out of a brep

$
0
0

@burkhart.johannes wrote:

Hey everyone,

at the moment I try my best to cut out a closed brep and the projection of this brep out of a larger brep (also a closed one). I deconstruct the brep and cut out all faces from the larger brep but unfortunately some faces are not considered in my example.

I have attached my Rhino and GH file. Thanks in advance

cutting_project.3dm (34.4 KB) cutting_project.gh (1.4 KB)

Posts: 1

Participants: 1

Read full topic

Help closing these curves?

$
0
0

@franeb_96 wrote:

Hey guys. I am almost done with this geometric construction. The only thing missing is that I need for this mush of lines to become closed triangles to plug the geometry into an analysis tool later (for context, it’s a gated community and these triangles are lots).

I have created the octogons as closed curves and the divisions are lines, so it looks ok but I am afraid closing the curves is actually gonna be a mess of point lists and trees. Does anyone know how to achieve this ?

Thank you in advance !

Posts: 3

Participants: 2

Read full topic


Bug in RenderMaterialTable()?

$
0
0

@frist wrote:

Hi,
I think there is something wrong with Rhino.Render.RenderMaterialTable. As far as I understand I should be able to access a specific render material in the document using scriptcontext.doc.RenderMaterials[index]. Tying to do this inside a GhPython script crashes Rhino 6 SR24. However the using the enumerator scriptcontext.doc.RenderMaterials.GetEnumerator()[index] works.

So maybe RenderMaterialTable.getitem is not implemented properly or list access is not supposed to work?

See you
Flo

Posts: 1

Participants: 1

Read full topic

Create data tree with series

$
0
0

@sincho wrote:

Hi there,

I’m new to the grasshopper.

I’m want to duplicate the points n times with a slider so that I won’t need to use the series component over and over again.

In order to do that, I want to use a data tree.

I tried with lists as in the screenshot below. I need to generate lists and keep the data in the tree and from there feed it to the XYZ point.

How can I achieve this? Any help is much much appreciated.

Posts: 2

Participants: 2

Read full topic

Data Stability Problem

$
0
0

@duanemclemore wrote:

Hi All,

This seems like it’s a C# / .NET problem, but I can’t find any answers in the wider community. Thanks in advance for your patience with my ineptitude.

I have a component Lattice Generator which feeds two sets of information into another component, Cell Generator

  1. a GH_Structure<GH_Point> with one point per branch.
  2. a List with eight vectors on it.

Cell Generator is then to take each Point and apply the List to it, making eight points from the one it was given, on a GH_Structure with the same branch address as the Point came in on. This isn’t quite working yet, but I have a bigger, nastier looking problem I need to sort out first.

This Cell Generator component has a couple other functionalities that come from the same component, each as a single string of information.

So - every time I plug something new into the Cell Generator, it causes the GH_Structure<GH_Point> values to increase.

I’ll get to code soon if necessary. Mine is so in progress and I’m still learning, so it’s a huge mess - probably less confusing for such a general question if I post screenshots…

Edited to add: in the CellGenerator component I am using a “foreach” loop to iterate over each GH_Point in the GH_Structure individually. I commented this out and the upstream problem goes away. Is there a good guide anyone can think of for using foreach statements on GH_Structures?

Thanks in advance for any help you can offer. Sorry for making such dumb problems!

Regards,

Duane

Posts: 1

Participants: 1

Read full topic

How to create separator Lines for inputs and Outputs?

$
0
0

@su.lwpac wrote:

Hi everyone, Anyone know how to create separator lines for inputs and outputs for components.
Here is an image reference from Ladybug Tool.

In these components, they created and input parameter with name as “-------”.
I am curious to know if we can actually define that while creating plugins in Visual Studio.

Posts: 1

Participants: 1

Read full topic

How to program a C# component in Visual Studio with "AutoList" capability?

$
0
0

@gieljan_vantyghem wrote:

Hi all, I’m finalizing a C# component in Visual Studio and I would like to add “AutoList” capabilities?
So that: when a ‘Value List component from Grasshopper’ is connected to the custom component, the list will get all possible values for that input. This is nicely illustrated on the following picture:


Can someone help me?
Kind regards

Posts: 4

Participants: 4

Read full topic

Inserting gh file by script

$
0
0

@bingwangus wrote:

Hi,

I found it very helpful to have the option to insert a .gh file when drag and drop. I wonder if there is a way to do the same job by script?

I know it is possible into open a .gh file with grasshopper.Plugin.GH_RhinoScriptInterface().OpenDocument(path).
I also found GH_DragDropFileAction Enumeration item.

But how to make them together?

Thanks.

Best
Bing

Posts: 1

Participants: 1

Read full topic

Changing density/thickness of voronoi struts

$
0
0

@aingrole wrote:

Hi,

I am trying to vary the density/thickness of the voronoi struts in my 3D model at certain distance. I have attached the file which is 40x40x20 voronoi model. I would like to change the density at every 10mm in length. Right now I was changing the thickness.
Also, please let me know if I am doing it correctly.
I inserted a point cloud to create the voronoi model.Try wit different area.gh (19.8 KB) New UEP.txt (4.5 KB)

Posts: 1

Participants: 1

Read full topic


Custom Preview - performance issues

$
0
0

@gieljan_vantyghem wrote:

Hi all
I’m developing a plug-in component in Visual Studio to ‘voxelize’ a random shape.
(i) First component generates a dataTree (or list) of points.
(ii) Second component makes ‘Center Boxes’.

I would like to add a custom preview to this second component, which will have different colors in a later stage… But I can’t seem to find the best method for this.

I’m testing the performances of different strategies in C# in GH; but I can’t seem to find methods that are as fast a the existing ‘Custom Preview’ component of GH. :frowning:.

Using the standard display method of GH is very fast. But I don’t like the transparency.
I’ve used ‘Preview Override’ (see code below), but it has a duration of 72 ms compared to 19 ms. How can I speed up this process? Any ideas anyone? I really need it to be as fast as possible. Voxel settings are still very coarse now.

Thanks! -Gieljan

//Draw all meshes in this method.
public override void DrawViewportMeshes(IGH_PreviewArgs args)
{
for (int i = 0; i < _boxes.Count; i++)
args.Display.DrawMeshShaded(Mesh.CreateFromBox(_boxes[i], 1, 1, 1), new
Rhino.Display.DisplayMaterial(_materials[i]));
}
//Draw all wires and points in this method.
public override void DrawViewportWires(IGH_PreviewArgs args)
{
for (int i = 0; i < _boxes.Count; i++)
args.Display.DrawBox(_boxes[i], System.Drawing.Color.Black);
}

Posts: 1

Participants: 1

Read full topic

Parametric Frames from curved Surface

$
0
0

@ogprostean wrote:

Hello All,
I hope you are all doing fine during this weird times.
I’m now working on creating a parametric desk and got stuck in the process. I attached two pictures and the rhino+grasshoper documents from the project.
There was a surface created which was modified using pointson and rebuild commend. Now what I’m trying to do is split the surface into frames and creata a certain depth and thickness to them. However it seems that the process goes wrong since the frames dont follow the curved path of the surface. It only does it on the x-axis. I’m a very very beginner with rhino and grasshopper. The system was also created with the help of some tutorials on youtube. I experimented in grasshopper this morning but cant find a solution to it.
I hope you can help me further with this issue.
Thank you very much and have a nice day :slight_smile:

the parametric desk.3dm (6.0 MB) parametric desk.gh (12.3 KB)

Posts: 1

Participants: 1

Read full topic

Populating a Mesh with 3D Voronois

$
0
0

@staycoolish wrote:

Hello everybody,

I think I have a trivial problem but I cannot solve. I want to populate a mesh with 3D voronoi cells. In order to do this, first I populate it with points, then make a 3D Voronoi diagram from those points and finally intersect two mesh sets. Intersection is not working properly, as you can see in the figure. I tried converting breps (3D Voronoi cells) to meshes, then the intersection returns nothing.

By the way, I was working with brep geometries (like a solid sphere) and making a Solid|Solid intersection (intersecting sphere with 3D Voronoi diagram), but it is not possible to convert an stl to brep (at least for a detailed object) I suppose. Solid | Solid intersection was working perfectly, but with meshes I cannot figure out what to do.

Posts: 1

Participants: 1

Read full topic

GH covid19 3D interactive graph CHARETTE (Edward Tufte style)?

$
0
0

@chertok22 wrote:

coming over from the old school GH forums so advance apologies if this is in the wrong place or off topic. but i have been following the east coast maker space forums on facebook where they have been basically full time charetting to come up with “makerspace made” protective gear. very interesting process.

and i cannot get my mind off the idea that there must be a way to produce a “Edward Tufte-esque” high content 3D chart of this coronavirus crises and to publish it for a real time accessible and interactive use in shape divers or something. something that would combine more variables into a 3D chart for intuitive professional or “civilian” use.

like even adding one more variable in the Y direction for a fully 3D graphic to some of these charts seems like it would be useful?!

i’m thinking something like one of edward tufte’s 3D charts in one of his books but i am not smart enough to know if this could be done. anyone think this is worthwhile enough to set up a facebook group for or a group mailing list?

the makerspace folks are coming up with great stuff and it is quite interesting.

edward tufte: https://en.wikipedia.org/wiki/Edward_Tufte
data: http://covid19.healthdata.org/united-states-of-america
data: https://www.npr.org/sections/health-shots/2020/04/07/825479416/new-yorks-coronavirus-deaths-may-level-off-soon-when-might-your-state-s-peak

anyway, thanks for the read. hit me up here or with a message if you’d like to see if this could be realized.

Posts: 1

Participants: 1

Read full topic

How to inflate tetrahedrons and pack them inside box

$
0
0

@nikca.wolkova wrote:

Hello Everyone,

I am currently working on an architectural project. I am trying to inflate tetrahedron inflatables inside a box and once they are inflated i would like them to pack in the most effiecient way.

I have downloaded a script and tweaked it so that instead of spheres i can inflate tetrahedrons - or practically any mesh i want. However there are a couple issues.

  1. The process takes ages - maybe because the meshes are too heavy?
  2. the meshes start protruding inside each other instead of colliding
  3. With growing pressure the meshes do not pack naturally as they would in reality. I tried to connect the gravity button to draw the inflatables to the bottom of the box, but the script stopped working. So the only way to organise the inflatables was manually using the grab tool.
  4. the script also does not work well with inflating meshes of various sizes - the small once end up being “absorbed” by the bigger ones and that is a shame.

If you please have any ideas on how to help me with the points above i would extremely grateful. I attach some images and script below.
Thank you
Niki


200409 rhino file.3dm (117.6 KB)200409 tetrahedrons inflated inside box.gh (19.7 KB)

Posts: 2

Participants: 2

Read full topic

Viewing all 3626 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>