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

Polyline and PolylineCurves, issue with invalid cast

$
0
0

@oliver_1992 wrote:

Hello.
I´m very unsure how to deal with curves of the type Polyline and PolylineCurves.
I did this simple grafting component to reproduce the error I get in another script I’m working on.
For my understanding, if I pass a Referenced Polyline Curve to my Grasshopper component, it is of a Polyline Type. So I convert it with ToPolylineCurve () to a PolylineCurve type, so I could use the methods of the Curve Class. Now I graft it and output a tree of PolylineCurves.
I get the error -> 1. Invalid cast: Curve » PolylineCurve
Does anybody know what I’m doing wrong?

    protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
    {
        pManager.AddCurveParameter("iPolyline", "iPolyline", "iPolyline", GH_ParamAccess.list);
    }

    protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
    {
        pManager.AddCurveParameter("oPolylineCurves", "oPolylineCurves", "oPolylineCurves", GH_ParamAccess.tree);
    }

    protected override void SolveInstance(IGH_DataAccess DA)
    {
        List<Polyline> iPolylines = new List<Polyline>();
        DA.GetDataList("iPolylines", iPolylines);

        List<PolylineCurve> temp = new List<PolylineCurve>();

        for (int i = 0; i < iPolylines.Count; i++)
        {
            temp.Add(iPolylines[i].ToPolylineCurve());
        }

        DataTree<PolylineCurve> oPolylineCurves = new DataTree<PolylineCurve>();
        
        for(int i = 0; i < temp.Count; i++)
        {
            oPolylineCurves.AddRange(new List<PolylineCurve>() { temp[i] }, new GH_Path(i));
        }

        DA.SetDataTree(0, oPolylineCurves);

    }

Thanks for reading my post.
Best wishes,
Oliver

Posts: 2

Participants: 2

Read full topic


String duplicates with list access GHpython

Output geometry clipped when larger than input geometry

$
0
0

@menno wrote:

I’m working on a component that outputs geometry that is much larger than the input geometry (see below, a grid of 20x20 rectangles gets clipped). Is there a way to prevent this?

Posts: 2

Participants: 2

Read full topic

Leader preview

$
0
0

@yuccheno wrote:

Hello guys,

I am trying to script in ghpython that is able to preview the leader (arrow, curve and text), instead of directly bake the leader object in Rhino.

The following script is my attempt. I did create the leader object, but it is not previewing in Rhino.

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import Rhino

ptts = Rhino.Collections.Point3dList(x)
dim = Rhino.RhinoDoc.ActiveDoc.DimStyles[0]
apts = Rhino.Collections.Point3dList.ToArray(ptts)

leader = rg.Leader.Create("test", y, dim, apts)
a = leader

Any help will be great! Thanks in advance.
leader_preview.gh (7.2 KB)

Posts: 1

Participants: 1

Read full topic

Leap Motion Test + How to bake by pressing a key?

$
0
0

@katharinastaerck wrote:

Hey Hey guys,

I’m teaching myself grasshopper right now and I have a question!
Currently I’m testing some stuff using the Leap Motion. I was wondering if there is a way to load the lofts I generate with it into Rhino with one keystroke instead of right-clicking Bake?

Is there a way to include the “beacon key” in the code?

I would also like to know if it would be possible to control the position of the baked bodies in Rhino? In other words, that each baked body is secured in a different position?

If necessary, I will try to upload my code here! :slight_smile:

THANKS IN ADVANCE
Kate

Posts: 1

Participants: 1

Read full topic

Regarding bowlbuilder

What methods in Rhinocommon does MergeEdge/MergeAllEdges call?

$
0
0

@MarkBaolinZhou wrote:

Hi,
I’m trying to merge the naked edges of a trimmed surface or open Brep in grasshopper, just like the MergeAllEdges command dose. I have looked up all Brep methods (including the methods from BrepLoos and BrepTrims) but couldn’t find anything similar. Any good idea?
Thanks!

Posts: 5

Participants: 5

Read full topic

Interoplate Curves based on Contours of Curve

$
0
0

@antoine.brabants wrote:

Hello,

I made “Contours” on curves which results in different points.

I would like to use these points to create some “Interpolated curves” in order to create a “Network Surface”.

Everything is fine at the exception of the box “Interpolated Curves” which is red.

Can someone help ?

Thanks,

Antoine

Test.gh (18.2 KB)

Posts: 1

Participants: 1

Read full topic


Twice as many PolyCurve segments as expected

$
0
0

@jason.danforth wrote:

Example.gh (18.3 KB)

Long time Grasshopper user, total C# / RhinoCommon noob:

I am trying to explode a polyline from grasshopper using C# and RhinoCommon. Each segment is one half of what I expected to get. By checking PolyCurve.SegmentCount I can see that the issue is with how the PolyCurve is instantiated, and not related to PolyCurve.Explode(). I have tried simplifying the initial Curve as well, but to no avail.

File is attached and code is below. Any advice would be greatly appreciated.

PolyCurve iPolyCurve = x.ToArcsAndLines(0.001, 1, 0.01, 1000000); //convert to PolyCurve to explode
B = iPolyCurve.SegmentCount;

Curve segments = iPolyCurve.Explode();

List edges = new List(); // iterate over Curve to create generic list for Grasshopper
for (int i = 0; i < segments.Length; i++)
{
edges.Add(segments[i]);
}

A = edges;

Posts: 2

Participants: 2

Read full topic

Professional Consultancy : Structure of New Generation of Airships (Zeppelin)

$
0
0

@charlie.lavie wrote:

Hello,

I am a designer and I work for the company FLYING WHALES, a zeppelin company.
As part of its design, we work on the structure of the airship in relation to its shape.
Thus, we would like to work on a parametric approach of the structure in order to be able to iterate on it.
And to do so, we are looking for an “expert” mastering the Grasshopper tool.

I allow to contact this forum to look for a Grasshopper Developer who would be interested to work us on this project ?

Below, you will find a brief explanation of the problem.

Hoping that my approach will be successful, I wish you a very good day.

Kind regards,


Request for Grasshopper Study for Flying Whales
An airship consists of a structure covered with a textile envelope cut into
different panels.


The first objective is to rationalize the panels of the outer shell (and potentially the structure) in order to have as few panel references as possible.

The structure of the airship is composed of a mesh of beams.
These beams are located on the periphery and reproduce a defined shape.
The purpose of the structure is to create the desired shape but also to support the forces.

Thus, the mesh and in particular the points of intersection between the beams are
defined by calculations. As this shape is complex (only one left/right symmetry),
the beams all have different references. The aim of the exercise is to reduce the number of beam references by standardizing them.

The objective is therefore to start from the existing mesh of intersection points
and thedeform “slightly” so as tobe able to reduce the reference number of
beams.

The image opposite illustrates this exercise: in grey the original shape
composed of all unique beams, in black the optimized shape composed
of a limited number of unique beams (reduction of the reference number;

The black form(optimized) is slightly offset in relation to the grey form (original).A
balance must therefore be found between reducing the number of references and
shifting from the original form.

Posts: 1

Participants: 1

Read full topic

Simple key/value sorting in C# with RhinoCommon

$
0
0

@jason.danforth wrote:

Total noob question, but can anyone explain how to sort the items in one list (values) using the items in another list (keys)? Must use RhinoCommon in C#. All I want to do is mimic the Sort List component in Grasshopper. Can’t make heads or tails of the documentation.

Would also be great to see how to sort the items in one list by itself (int and string).

Thanks!

Posts: 5

Participants: 4

Read full topic

Teleporting component

$
0
0

@christopher.ho wrote:

Hi I am currently developing a grasshopper component and have run into an issue where the component will relocate itself to the top left corner every time I reopen the script and disconnect all of it’s sources.
However, the values it holds as part of deserialization are kept.

I was wondering if anyone has experienced this before?

Posts: 1

Participants: 1

Read full topic

GH stopped writing to Rhino CommandLine (RhinoApp.WriteLine("..."))

$
0
0

@RIL wrote:

Now I feel a bit lost. Suddenly GH no longer writes to the Rhino command line from GH script components when calling “RhinoApp.WriteLine” from C#. Is there a setting somewhere which I accidentally disabled or is it just Rhino prowling me?

// Rolf

Posts: 1

Participants: 1

Read full topic

The breakpoint will not currently be hit. No symbols have been loaded for this document

$
0
0

@feklee wrote:

Following the guides Installing Tools (Windows) and Your First Component (Windows), I installed Visual Studio 2017 Community Edition and created the HelloGrasshopper component. Everything works fine except for debugging. After running in debug mode and inserting the component, the example breakpoint is hit (it is!). Nevertheless, I get a message:

The breakpoint will not currently be hit. No symbols have been loaded for this document.

Furthermore, the Locals and Autos tabs are empty. I tried manually loading the symbols from the Modules window. When I select HelloGrasshopper.pdb, I get: A matching symbol file was not found in this folder.

How can this be fixed?

Posts: 1

Participants: 1

Read full topic

Convert IGH_Goo to integer

$
0
0

@aleksanderdynarek wrote:

How to convert Grasshopper.Kernel.Types.IGH_Goo to integer?

I have a class which inputs a DataTree (of ints) from Grasshopper. Then it need to take its values from different branches and add to List.

Posts: 7

Participants: 3

Read full topic


Maximise non-overlapping curves from set of overlapping curves

$
0
0

@t.sutherland wrote:

Hi everyone,

I was wondering if anyone could help with this problem. I have a set of planar curves (all rectangles but I imagine the same process would work with any non concave shape) where most of them overlap with at least one other curve. Is there a process where you can input these curves and it will return the largest set of curves where non of them overlap.

I’ve made a basic attempt but I imagine the optimal way to do it will involve an iterative process.
MaxOverlappingCull.gh (23.9 KB)

Thanks in advance

Posts: 6

Participants: 2

Read full topic

How to use IGH_VariableParameterComponent in component written in ghpython?

$
0
0

@Miracle_arc wrote:

Hi all,
I want to creating custom component with variable number of inputs, but after searching the forum, none on this. I tried to implement in ghpython, but seems the input number is not as that in C#:

Why it takes 3 arguments? according to this:
https://developer.rhino3d.com/wip/api/grasshopper/html/T_Grasshopper_Kernel_IGH_VariableParameterComponent.htm
I suppose 2 arguments is enough, am I losing something?
Since the first time compiling my own components, and I have no knowledge about C# or VB. That’s no suprising my method is totally wrong. :sweat_smile:

Posts: 4

Participants: 2

Read full topic

Item Index

Automatically start Grasshopper without banner?

$
0
0

@feklee wrote:

For debugging components, I want to enter Grasshopper as quickly as possible. So I set up in my Visual Studio project as Rhino command line arguments:

/runscript="!-_grasshopper _Banner _Disable _Window _Show" /nosplash

However, the banner in Grasshopper still shows and needs to be closed by a click before I can continue.

By the way, to increase startup time of Rhino, it would be nice if there was a way to disable loading of all plugins except for Grasshopper.

Posts: 1

Participants: 1

Read full topic

How can I make my python type visible in rhino viewport?

$
0
0

@grasshoppertrainer wrote:

Hello y’all fellow trainers.
I’ve been craving for the answer and got into the point where the only thing left is to ask directly.
What I’m trying to do is to make grasshopper display preview geometry for my(written inside a ‘Pyton script’ component) python type(class).
So, Inside the component, I’ll produce an instance which includes a grasshopper geometry(ex. mesh) as an parameter with bunch of other class-specific parameters(ex. self.the_mesh = x, self.index = 0…).
I can return this instance and use it inside another custom component.
But the thing it doesn’t do is to draw preview on rhino viewport like returning simple grasshopper mesh object would do.

I’ve read various topics about custom previewing regarding GH_Goo or IGH_PreviewObject, IGH_PreviewData but still can’t understand it. Most of them where about VB and I think that’s why.

Thinking of render pipeline I can imagine of two aproaches;

  1. Grasshopper reads components property to render preview so I need to pass Myclass().geo to MyComponent.some_assigned_parameter.
  2. Grasshopper reads every output of a component so Myclass need to inherit grasshopper built-in class as a protocol and some of its parameter or method has to be overriden to coop with Myclass().geo.

I do understand intermediate python syntax like inheritence, overriding parent’s method etc.
Please give me an insite.

Thank you.

—following is my script—

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper, GhPython
import System
import Rhino
import rhinoscriptsyntax as rs

class MyComponent(component):     
    def RunScript(self, x):
        # input x is as list including a grasshopper geometry object
    
        class Myclass:
            def __init__(self, data):
                # 'geo' is a representative parameter of an instance
                self.geo = None
                for i,d in enumerate(data):
                    if isinstance(d, System.Guid):
                        self.geo = rs.coercegeometry(d)
                        data[i] = self.geo 
                self.data = data
                
        b = Myclass(x)
        return b
        # want to make this 'MyComponent' draw self.geo on rhino viewport

Posts: 7

Participants: 2

Read full topic

Viewing all 3630 articles
Browse latest View live


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