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

Finding arc properties C#

$
0
0

@Philippe_HAMON wrote:

Hello
I’m very new to c# scripting. I don’t find how to get the radius of an arc (or where to get the c# method for that…), I’m able to get the lenght, the start and end points, but not the radius…
my definition:
curves properties.gh (6.9 KB)

I’d like to include this radius information through an “if the curve is an arc, get his radius…” loop

Posts: 2

Participants: 2

Read full topic


Remove Jagged Edge

$
0
0

@jeremy.graham wrote:

Hi guys,

On a basic component, using GH_Component, is there a simple way of removing the JaggedEdge and just provide capsule with no input circle when there are no inputs or do I need to override the component input attribute?

thanks,
Jeremy

Posts: 1

Participants: 1

Read full topic

Tree problem: once I moved a set of points, the tree structure changed completely

$
0
0

@vapeurz wrote:

微信截图_20200427120816

The previous points are in a usable tree structure, I did nothing but simply moved it up, and the tree structure changed…I don’t know how to make it back. I’ve tried match tree from human, but it renders the same result.

If anyone could help!

Many thanks!

Posts: 2

Participants: 1

Read full topic

Change vertices color of a mesh

$
0
0

@dome.gaudioso wrote:

Hello guys, I would like to output two different colored meshes after creating the geometry of the first mesh.
can someone help me?
I recently started using python on grasshopper.

Thanks.
Domenico

This is my script in python with rhinocommon:
meshColours.py (658 Bytes)

Posts: 2

Participants: 2

Read full topic

How to use Input.Keyboard in GH COMPONENT

How to not run my component every time I change my InputParams?

$
0
0

@18664777743 wrote:

I have a input param called A which will refresh every 50ms. But I don’t want my component to run every 50ms. I hope that my component run only if I disenable and enable it.

Posts: 3

Participants: 2

Read full topic

Possible to get the input values by index instead of name?

$
0
0

@p1r4t3b0y wrote:

Hi everybody,

Is it possible to get the values of a component input by index, instead of the input name?
I want to get the data from an input, independent of changes to its name. The input is part of a GHPython component,

Thanks.

Posts: 2

Participants: 2

Read full topic

Linking SketchUp with Grasshopper

$
0
0

@khademi.hr wrote:

Dear All,
Hello, I kindly reach you to inform you that six years ago, Kaveh Alagheband (https://www.youtube.com/watch?v=ctkvSMAuCrI&t=5s ) developed useful plugins which are Linking SketchUp and Grasshopper to each other, but unfortunately he didn’t develop it anymore.
I wonder to ask everyone who can develop this essential plugin. Thanks in advance.

Sincerely,
Reza

Posts: 1

Participants: 1

Read full topic


Loading embeded resources on Grasshopper for Mac - PriorityLoad()

$
0
0

@thomas.william.lee wrote:

Hello
I’m developing a plugin for Grasshopper and I’m loading my assemblies from embedded resources via the GH_LoadingInstruction -> PriorityLoad().
I’m subscribing to the AppDomain.CurrentDomain.AssemblyResolve event and feeding the corresponding dll on request as stream from GetManifestResourceStream. This works fine on Windows and all my dll’s are loading fine from inside when needed.
However on Mac it’s not working. I cannot even get a response from the PriorityLoad() when starting Grasshopper which is weird, not even a RhinoApp.WritelLine reponse during load. When I externalize the dll’s it’s working fine, but I’m very interested in keeping them embedded.

Is PriorityLoad not implemented in the mac version or what could be the issue? Could it be permissons? The GHA is built on windows.

Snippet:

public class Start : GH_AssemblyPriority
{

private readonly string[ ] assemblies = { "...................

	public override GH_LoadingInstruction PriorityLoad()
	{
		RhinoApp.WriteLine(" !!!! PriorityLoad !!!!");
		AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

		return GH_LoadingInstruction.Proceed;
	}

	public Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
	{
		AssemblyName assembly = new AssemblyName(args.Name);
		RhinoApp.WriteLine("Requesting assembly: " + assembly.Name);
		if (assemblies.Contains(assembly.Name))
		{
			return LoadStream(assembly.Name);
		}

		return null;
	}

public Assembly LoadStream(string assemblyName)
	{ .....................

Posts: 1

Participants: 1

Read full topic

Question about - rs.VectorReverse

$
0
0

@senakurkcuoglu wrote:

Hi;
When the distance between the red points and the point decreases, I want to reverse the vectors. The code does not fail but is not working. Can you help me?

import rhinoscriptsyntax as rs

def rotated():
red = rs.coerce3dpointlist(red_)
point=rs.coerce3dpoint(pointID)
distances=rs.Distance(red,point)
if distances < 8.00 : return
vector=rs.coerce3dvector(vector_)
vector2 = rs.VectorReverse([1,0,0])
print vector2

Posts: 3

Participants: 3

Read full topic

C# coding - div list of curves

Mesh Mesh Intersection

$
0
0

@Petras_Vestartas wrote:

Hi,

I would like to ask if there is an existing RhinoCommon method that could help me identify mesh faces that touch each other. MeshMeshFast or MeshMeshAccurate outputs geometry only (lines or polylines). This I use just for identifying if meshes are colliding. But I am trying to find out touching mesh faces id.

First I was thinking that I could somehow search coplanar planes. But since meshes could have many faces, the search could be slow.
Is the only way:

  1. iterate over each mesh face
  2. get its center
  3. search mesh closest-point
  4. skip result if distance between two points is bigger than a tolance?


File.3dm (95.4 KB)

Posts: 4

Participants: 3

Read full topic

Problem understanding why the index is out of range using "datatree.PathExists(x)" methode

$
0
0

@Baris wrote:

Hi,
I cant understand why its throwing this exception.I understand the index is too high, for my tree, thats why I was checking it with the pathExists methode.

It has to be very simple, I am already spending too much time without understanding.
maybe someone could point it out for me. I would be really grateful.

Thanks and nice sunday evening!
indexException.gh (19.0 KB)

Posts: 5

Participants: 3

Read full topic

Accessing Number of Branches

$
0
0

@duanemclemore wrote:

Hi All, I hope everyone’s staying healthy and safe in these crazy times.

I have a script which writes data to a 3-level nested tree {a,b,c}
I’m trying to find the number of unique path numbers in each “dimension,” a b and c.
[edited to add - I’m writing this in C#]

Imagine this as the addresses in a 3 dimensional grid. Say a is 3, b is 4, and c is 5. I would have lists

{0,0,0}
{0,0,1}
.
.
{0,1,0}
{0,1,1}
.
.
{0,1,4}
{0,2,0}
.
.
on to
{2,3,4}
{2,3,4}

So as you can guess, I don’t want a count of paths with that dimension (as that would just be 60 (3x4x5) for all three), I want those values to return 3,4, and 5. Or, it could be thought of as the largest value for any given branch of a path.

I tried Branches[n].Count and Paths[n].Length (where n is the integer of the number of the path) and it just returns a value of 3…

Basically, what I’m trying to do is test for a condition so that on every path with a {3,n,n}, {n,4,n}, or {n,n,5} in it something happens.

It seems like both count and length would also return the product of 3x4x5, as each of the (3) indices of the paths at {a, , } repeats (4x5) times. So I would need to find the max number in each dimension, or the size of the set of each unique dimension a, b, or c of the path.

As for a code sample that would help facilitate this, there’s nothing I could add that would help, as I’m generating these trees in a different component and trying to bring them in to this component and operate over them. If I were doing this test in the component where the trees are generated this would be easy, but I’m trying to split different functions to different components.

Thanks in advance for any advice!

Posts: 5

Participants: 2

Read full topic

Agents on point grid 2d[,] on surface UVs problem - flipped

$
0
0

@aleksanderdynarek wrote:

Hi guys

I have a very weird problem. Recently i am developing my own namespace of classes in C# with vector fields,pheromones, boids slime mould etc. I have class with VectorPheromoneField (contains 2d or 3d grid, built with arrays, with VectorPheromonePoint class - containing position, vector and int value). Agent class contains function to search a closest point in field grid, project searching points in front of it etc. Basically a Slime Mould logic but opened to experimentation.

While searching for info in the web, i came across and idea to project a 2D grid on surface UVs. I have tried to implement it, but i came across this weird effect:

White cloud points are outputted from VectorField (color and alpha is pheromone int value) and red dots are agents. In every other VectorField that i scripted without projection on surface agents where directly following pheromones traces, which is obviously logical. But here agents seem to be somehow flipped, even if the pheromone pattern is built properly (exeactly like it would be with a VectorField 2d grid not on surface).

I am decent in scripting points, vectors etc but a bit of a newbie in NURBS. What may be the reason?

-grid is based on a function that i wrote SurfaceDivide (grid [,]) which outputs PointAt from surface using reparametrised domain
-agent searches for strognest pheromone point using three vectors in front of it, two rotated and one frontal, and finds a pheromone point from 2d grid closest to the projected vector
-then agent is moved accordingly and projected on surface using ClosestPoint and PointAt.

What may i have done wrong?

Posts: 1

Participants: 1

Read full topic


How do I "assign" a number to cells?

$
0
0

Hi everyone,

I am following the Generative Landscape tutorial to create a “fur pattern” cellular automata output. It’s a really fun tool and I am trying to customize it a little bit. (https://generativelandscapes.wordpress.com/2015/06/19/activator-inhibitor-fur-pattern-example-12-1/)

Essentially on a square grid, the inputs are assigned a 0 or 1 through the Random component. This goes through a CA-like loop, and the result looks like a self-organized fur pattern, still based on whether the cell is 0 or 1.

I have two questions:

Question 1. How can I control how much % of the cells is 0 or 1 at the beginning? I would like to use something like Random Reduce, so that I can control how much % of the grid is 1, but their locations being random.

So far I’ve faked this by using Split List and feeding them into two (or more) Random components, one of which has the range of “0 to 0” and the other “1 to 1.” This does work but I’m curious if there is a better way to do this.

Question 2. This is not relevant to the CA script, but I am curious if there was a way to “assign” more than two numbers to cells on a grid, random or not, so that I can color the grid in multiple ways, much like a cross stitching pattern. I am imagining that this would expand on the method from the 1st question.

I can see using a panel, multiline, and inputting numbers and having them Repeat Data, but I wonder if it could be more intentional than that. Has anyone potentially done this already?

Thank you so very much in advance. I have some grasp of GH but when it comes to the data side of it I still lack a lot of practice.

Best,
Sue

2 posts - 2 participants

Read full topic

Help with Smog-Eating Building Façade

A Timer component Bug? an Ultra simple experiment!

$
0
0

I write a c# component to test timer component:

image

and connect a timer to it,interval is 1 second.
so the number add 1 every one second.
then i change interval to “10ms”,so the number will add 100 every one second
image
image
but in fact it not,almost need 3 seconds to add every 100.
it seems a bug in timer.
who can explain that,thank you!

3 posts - 2 participants

Read full topic

Visualizing custom hierachical objects

$
0
0

Hey there,

I am implementing a set of my own objects (i.e. Python classes) that contain different representations of the same geometry. For example a Wall, can have Brep, Lines, Points, …

Is there a way I can define a default visualization such that when I select a component that outputs my objects (say, walls) in grasshopper it displays them as surfaces? A work-around is currently to access the underlying geometry in a separate component (like wall.surface)

I can’t really get my head around that, but other solutions like the BHoM elements do something similar. Like in the image below, where the visualization is comprised of the wall surface as well as the openings in that wall. I just could not find the respective code that does it…

Thanks a lot in advance!
Best,
Max

1 post - 1 participant

Read full topic

Deep and Shallow DataTree constructor

$
0
0

Hello everyone, I have a beginner question regarding C#.

I’m writing a 3D Game of Life script with an DataTree input sorted by 3D coordinates {z,y}(x).

However it’s not working as intended and I want to rule out it might be caused by using a shallow DataTree copy:

DataTree < int> storage0 = new DataTree(init);
DataTree < int> storage1 = new DataTree(init);

What is the difference between a deep and shallow copy? Could you please help me how to use the deep constructor?

DataTree < T > (DataTree < T > , DataTree < T > .DuplicateT - Create a true duplicate of another data tree.

Thank you,

Cheers
Jonas

3 posts - 3 participants

Read full topic

Viewing all 3630 articles
Browse latest View live