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

Texturing lines?

$
0
0

I’m working on a Grasshopper application that could benefit from the ability to display line segments with texture. Is there a way to do this within the context of the Grasshopper development environment?

Related idea: OpenGL supports textured line segments… is OpenGL accessible from within DrawViewportMeshes? (Back in the day we used to use OpenGL commands within a C++ display conduit to render auxiliary geometry alongside Rhino’s display.)

3 posts - 2 participants

Read full topic


Pattern Perforation normal to surface

$
0
0

hello. i m a newbie and i m trying to create a pattern on a revolved surface. i ought to think there must be a more efficient way to create the set of holes on each iso curve than isolating each line and creating a set of circles. Looking for advice and tips to make this more agile and efficient.

thanks

2 posts - 2 participants

Read full topic

Convenient collection of Naked Edge Indices info

$
0
0

I want to collect topology info for naked edges, and I want this “organized” per naked edge. With this I mean like (imagine a new curve type): “PolyEdgeLine” defined as follows:

    TopologyEdge Index (TEI)
    TopologyEdges.TopologyVerticesIndex (TETVI) // same as IndexPair info

Put together I want all the index info about an edge in the same order as the edges occur in a regular (NakedEdge) Polyline[], like so:

struct PolyEdgeIndices
{
    int TE_I;  // Topology Edge Index
    int TETV_I; // First Topology Edge (Topology) Vertex Index
    int TETV_J; // other end
}

// "Poly Edge Line"
PolyEdgeIndices[] NakedEdgeIndicesInfo;

The above info can be easily retrieved for individual edges by traversing the MeshTopologyEdgeList , but it takes some computation to piece together the naked edge segments to form a continuous “PolyEdgeLine”, so to speak.

Is there any convenient way to gather all this Edge info in this ordered way, or do I have to piece together the segments (and its index info) myself?

I’m aware of the mesh.GetNakedEdges() command, but the result type (Polyline[]) doesn’t give me any of the indices I want as in a ordered, connected, “PolyEdgeLine” way (with the index of the edge and indices of it’s vertices).

I need this (index) info for (multiple cases) of of edge analysis, which is why I want it in “compacted” form to simplify my code.

// Rolf

2 posts - 2 participants

Read full topic

Missing Nulls! Flip Data Matrix Custom C# output Error

$
0
0

I am working on creating custom Flip Data Matrix Function, which will divide an input tree into subTree of similar path indices i.e; {0;} as one tree and {1;} as another and so on. I tested the Custom flip data function on one of the subTree and it works. But when I iterate the whole function over the subTrees it fails to generate the nulls. Here is the snippet from the GH-Canvas.

Here is the Code of the complete process of Split tree & Flip Data Matrix

using System;
using System.Collections;
using System.Collections.Generic;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;



/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
  /// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
  /// <param name="text">String to print.</param>
  private void Print(string text) { /* Implementation hidden. */ }
  /// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
  /// <param name="format">String format.</param>
  /// <param name="args">Formatting parameters.</param>
  private void Print(string format, params object[] args) { /* Implementation hidden. */ }
  /// <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj) { /* Implementation hidden. */ }
  /// <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj, string method_name) { /* Implementation hidden. */ }
#endregion

#region Members
  /// <summary>Gets the current Rhino document.</summary>
  private readonly RhinoDoc RhinoDocument;
  /// <summary>Gets the Grasshopper document that owns this script.</summary>
  private readonly GH_Document GrasshopperDocument;
  /// <summary>Gets the Grasshopper script component that owns this script.</summary>
  private readonly IGH_Component Component;
  /// <summary>
  /// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
  /// Any subsequent call within the same solution will increment the Iteration count.
  /// </summary>
  private readonly int Iteration;
#endregion

  /// <summary>
  /// This procedure contains the user code. Input parameters are provided as regular arguments,
  /// Output parameters as ref arguments. You don't have to assign output parameters,
  /// they will have a default value.
  /// </summary>
  private void RunScript(DataTree<Point3d> pts, ref object A)
  {
    GH_Structure<GH_Point> sortedData = new GH_Structure<GH_Point>();
    GH_Structure<GH_Point> outData = new GH_Structure<GH_Point>();
    List<int> pathIndices = new List<int>();
    DataTree<int> pathTree = new DataTree<int>();
    GH_Structure<GH_Point> ghStructure = new GH_Structure<GH_Point>();
    GH_Structure<GH_Point> ghStructureOut = new GH_Structure<GH_Point>();
    DataTree<GH_Point> ptsShow = new DataTree<GH_Point>();



    for(int i = 0; i < pts.BranchCount;i++)
    {
      var branch = pts.Branch(i);
      var path = pts.Path(i);

      for(int j = 0; j < branch.Count;j++)
      {
        GH_Point myPts = new GH_Point(branch[j]);
        sortedData.Append(myPts, path);
      }
    }


    for (int a = 0; a < pts.BranchCount;a++)
    {
      var branches = pts.Branches[a];
      var paths = pts.Paths;
      for (int b = 0; b < paths.Count; b++)
      {
        if(paths[b].Indices[0] == a)
        {
          pathIndices.Add(a);
        }
      }
    }
    var uniqueItems = new HashSet<int>(pathIndices);

    DataTree<GH_Path> sortedPaths = new DataTree<GH_Path>();

    for (int j = 0; j < uniqueItems.Count; j++)
    {
      for(int i = 0; i < pts.BranchCount;i++)
      {
        var path = pts.Paths[i];
        if(j == path.Indices[0])
        {
          sortedPaths.Add(path, new GH_Path(j));
        }
      }
    }

    for (int a = 0; a < sortedPaths.BranchCount;a++)
    {
      var branches = sortedPaths.Branch(a);


      for (int b = 0; b < branches.Count; b++)
      {
        int i1 = 0, i2 = 0;
        if (branches[b].Indices[0] == a)
        {
          sortedData.PathIndex(branches[b], ref i1, ref i2);
          outData.AppendRange(sortedData.Branches[i1], branches[b]);
        }

        //Flip Data Matrix Function Runs here inside the Loop
        int length = outData.Paths[0].Length;
        int num1 = outData.PathCount - 1;
        for (int index = 1; index <= num1; ++index)
        {
          if (outData.Paths[index].Length != length)
          {
            Component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "All paths must have the same length");
            return;
          }
        }
        int index1 = -1;
        if (outData.PathCount == 1)
        {
          index1 = length - 1;
        }
        else
        {
          int num2 = outData.PathCount - 1;
          for (int index2 = 1; index2 <= num2; ++index2)
          {
            int num3 = length - 1;
            for (int index3 = 0; index3 <= num3; ++index3)
            {
              if (outData.Paths[0][index3] != outData.Paths[index2][index3])
              {
                if (index1 < 0 || index1 == index3)
                {
                  index1 = index3;
                }
                else
                {
                  Component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "All paths may only differ at a single Position");
                  return;
                }
              }
            }
          }
        }

        int index4 = 0;
        do
        {
          List<GH_Point> ghGooList = new List<GH_Point>();
          GH_Path path = new GH_Path(outData.Paths[0]);
          path[index1] = index4;
          bool flag = false;
          int num2 = outData.PathCount - 1;
          for (int index2 = 0; index2 <= num2; ++index2)
          {
            if (index4 < outData.Branches[index2].Count)
            {
              ghGooList.Add(outData.Branches[index2][index4]);
              flag = true;
            }
            else
              ghGooList.Add(null);
          }


          if (flag)
          {
            ghStructure.AppendRange(ghGooList, path);

            ++index4;
          }
          else
            break;
        }
        while (index4 <= int.MaxValue);

        //Flip Data Matrix Function Ends Here
        outData.Clear();
      }

      ghStructureOut.MergeStructure(ghStructure);
      ghStructure.Clear();
    }


    for (int i = 0; i < ghStructureOut.PathCount;i++)
    {
      var branch = ghStructureOut.Branches[i];
      var path = ghStructureOut.Paths[i];
      ptsShow.AddRange(branch, path);
    }
    A = ptsShow;



  }

  // <Custom additional code> 

  // </Custom additional code> 
}

Also Attached is the GH Script. Here : SubTree & FlipDataMatrix-V2.gh (18.6 KB)

Anyone can you help, what could be wrong?

6 posts - 3 participants

Read full topic

Checklist inside the component

$
0
0

I am creating a plugin and I need to create e component with a “combo box” like in the following picture:


I found this in the book of Arturo Tedeschi - AAD. Probably it is part of Karamba but I am not sure. How can I create this in C#?

2 posts - 2 participants

Read full topic

GhPython rs.Messagebox messing up grasshopper selection

$
0
0

I’m trying to create a pop-up message box using ghpython and getting some strange behaviour. Every second time I press the toggle to activate the window and pressed ok in the messagebox the grasshopper interface becomes partially unresponsive: I cannot select components and I cannot window select anything. Hovering over inputs still shows the information on input and output. It stays like this until I press the boolean button again.
Here’s a video showing the behaviour on my computer:


200716 Python messagebox.gh (3.0 KB)
Running Version 6 SR27

2 posts - 2 participants

Read full topic

Save ShowCheckListBox() data

Error while parsing SHP

$
0
0

Hello,

When I try to use the SHP node in Grasshopper, I get the following error:

  1. Error while parsing RECREATION_Playgrounds: The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine.

I saw there were a few other posts that had this and it seemed from those posts that the solution was to install the Microsoft Access Database Engine 2016 Redistributable (https://www.microsoft.com/en-us/download/details.aspx?id=54920)
I installed the 32 bit version of that but it didn’t work and I’m still getting the error above.

Is there anything else I could try?

Thanks,

Lynn

1 post - 1 participant

Read full topic


FYI: ConcurrentBag fooled me for hours - why?

$
0
0

OK, I just recovered from a phenomenon (bug?) which really had me puzzled. I was collecting mesh edges, and I was doing so in parallel using a ConcurrentBag list-type to store my edge info. But I kept getting my edge lines flipped in arbitrary directions. I tried to skip the Parallel.For-loop and revert to a regular for-loop, but edges kept flippin’.

After “many hours” of debugging I finally tried to replace the ConcurrentBag (which I had introduced together with the Parallel.For-loop) with a regular List and voila! The edges (directions) started to behave again!

Just to demonstrate what I did:

    // **Skipping parallel & ConcurrentBag fixed the flippin' edges!**

    //var edge_segment_info= new ConcurrentBag<MeshEdgeIndexInfo>();
    var edge_segment_info= new List<MeshEdgeIndexInfo>();

    for (int i = 0; i < _TE.Count; i++)
    //Parallel.For(0, _TE.Count, i =>
    {
      var connectedFaces = _TE.GetConnectedFaces(i);
      if (connectedFaces.Length == 1) // = is naked
      {
        // Edge Vertice info
        var edge_segm = new MeshEdgeIndexInfo(i); // sets .TE_I = i
        var pair = _TE.GetTopologyVertices(i);
        edge_segm.TV_I = pair.I;
        edge_segm.TV_J = pair.J;
        edge_segment_info.Add(edge_segm);
      }

Q: How is it possible that the edges could get messed up due to using ConcurrentBag?

In any case, back to using arrays.

// Rolf

1 post - 1 participant

Read full topic

Set toggle to false after running stuff

$
0
0

I’m using “False Start Toggle” so i don’t run something accidentially.

when I toggle it, after the solution ends I popup a window that says “sucessful ran script”… then I want to reset the toggle to false for the next run.

I’m not using a button because it crashes randomly with no regard for the law.

is this possible?

i wish there was some meta-scripting capability so i do stuff like “set the state of component X to off”

I tried using metahopper but it doesn’t recognize this component, or even the default toggle component as far as I can tell.

3 posts - 2 participants

Read full topic

Issue with PointCloudKNeighbors in Python Grasshopper

$
0
0

Hello everyone,
I’m kind of new to python scripting in grasshopper and having an issue with the module “PointCloudKNeighbors”.

What I’m trying to do is generate a point cloud that would be divided into clusters of different sizes.
So I populated a geometry as per the sum of sizes the clusters then I’m trying to run a loop with python which would pick a point, find n (size of first cluster) closest points to it then pick point n+1 and do that again (with another size of cluster). So I am using PointCloudKNeighbors but once I change the amount, the list becomes unreadable and I cannot use its elements.

Anyone knows what’s the issue here and can solve it? (GH attached)

Thanks a lot !!

PointCloudKNeighbors_error.gh (13.4 KB)

6 posts - 2 participants

Read full topic

Display surface while C# Grasshopper component is running

$
0
0

Not sure if this is such a simple question that no one needs to ask it, or if the answer is so difficult to implement that no one wants to answer it?! I want to update the Rhino document image while my C# plug-in component is running. I’m doing a Simulated Annealing optimisation of a surface (a concert hall interior geometry) that requires 400 or more grid points. That’s too many sliders for Galapagos! I’d like to see each iteration of the geometry as the optimisation algorithm progresses. Any help will be greatly appreciated. Thanks in advance.

John O’Keefe

5 posts - 3 participants

Read full topic

Input in resizable component

$
0
0

Hi all ,

I’m trying to make a custom component (using C#) which is resizable, so I’m making a attribute class that inherits from GH_ResizableAttributes. It’s a bit of a struggle atm, since I’d like my component to have a input, but I can’t get it to work. By overriding the Render-function, I can draw an input grip, but I can’t use it… It’s like Grasshopper doesn’t know it’s there, even though I’ve also added the input in the component-class.

I’m thinking I might need to add something in the Layout-function too, but I can’t figure out how/what? So I would really appreciate if anyone has any inputs on this!

In my GH-component class I have;

public class MyComponent: GH_Component
………

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddIntegerParameter(“Numbers”, “Numbers”, “Numbers”, GH_ParamAccess.list);
}

Then in my attributes-class:

public class ComponentsAttributes: GH_ResizableAttributes

protected override void Layout()
{
base.Layout();
//---- ?
}

protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
{
base.Render(canvas, graphics, channel);

        if (channel == GH_CanvasChannel.Objects)
        {
            GH_Palette palette = GH_Palette.Normal;
            GH_Capsule capsule = GH_Capsule.CreateCapsule(Bounds, palette);
            capsule.AddInputGrip(this.InputGrip);
            capsule.Render(graphics, Selected, Owner.Locked, true);
        }

}

1 post - 1 participant

Read full topic

Modify Wires after instantiate component

$
0
0

Hi, this is my first post !
Im trying to write a script that instantiate a component and then generates connection to another component.

parentObject.Params.Output[0].AddSource(createdObject.Params.Input[0]); do the job in the debugger but when I see the canvas there’s no wire or connection.

I have tried to suscribe to Grasshopper.Kernel.GH_Document.SolutionStartEventHandler() and call .addSource from there, but doesn’t seem to create the connection.

Also tried using ScheduleSolution and call .addSource from there, but I got the same result.

I will be happy for any comments or suggestions how to solve this issue. Thanks!

1 post - 1 participant

Read full topic

Grasshopper assistance request

$
0
0

4.gh (12.6 KB)
hello everybody, I have a problem with these code…i can’t see list c in visual part in rhino…and I have no error in my script in python but I can’t find the problem.
can you please help me

2 posts - 2 participants

Read full topic


Disabling dragging the canvas in c#

$
0
0

I’m writing a very peculiar plug-in and I’d like to disable dragging the canvas, every method I’ve tried doesn’t work. I set the canvas focus and zoom easily and it does snap back to the focus, but for this use case I’d really like to stop the user from being able to drag the canvas, if possible.

4 posts - 3 participants

Read full topic

How to calculate maximum fillet radius between two lines?

$
0
0

I’m writing a Grasshopper component that fillets lines with Curve.CreateFilletCurves. Sometimes it fails because the fillet radius is too big. Is there an easy way to calculate the maximum fillet radius between two lines that are not necessarily at right angles to each other? If one of the lines is trimmed to zero length, is that considered an invalid fillet with the above method?

4 posts - 2 participants

Read full topic

Eto Webview ExecuteScript returns empty

$
0
0

Hi All,

I’m using Eto.Webview in an attempt to create a better looking UI. At the moment I’m trying to return the value of an element from the webview however it is returning empty when it definitely has a value in the html. Am I executing the script correctly?

    def GetText(self):
        return self.webview.ExecuteScript("document.getElementById('id').value;")

1 post - 1 participant

Read full topic

Output of custom component with generic parameter is updated with value of ouput of next connected component

$
0
0

Hello,

Version :
I’m creating my first set of components using Visual Studio Pro 2013 and Grasshopper Assembly for v5 with Rhinoceros 5.0.

However I have encounter an unexpected behavior that may be linked to a misunderstanding from my side ?

Context :
So far, I have 3 components :

  • CreateGraphComponent : it takes a set of curves and put them in a Graph Structure (the nodes have endpoint values, the edges have curve data)

  • CleanGraphComponent : it cleans the graph based on tolerance inputs (it removes some curves, or join some of them, to have a better graph structure)

  • GetCurvesComponent : it outputs all the curves from the structure.

Issue :

  • The output from CreateGraphComponent is changed and equal to the output of the CleanGraphComponent. I’m expected it to not change whether it is connected to another component or not.

Question :
Is it something expected when using Generic Parameter ?
Is it a bug or am I forgetting something ? How can I prevent that ?

This is my first post so I hope I did this post correctly.
I have not included the Grasshopper files as it is custom components in debug mode.

Thanks for your help

1 post - 1 participant

Read full topic

Eto.Form in C#

$
0
0

I’m trying to learn to use Eto.Forms. I found quite informative Python guide on:

https://developer.rhino3d.com/guides/rhinopython/eto-forms-python/

But I’m not able to transform it to C#. Is there any beginner tutorial for Eto.Forms in C# (in Grasshopper)?

I’m not even able to import Eto library by:

using Eto.Forms;

which throws me error:

Error (CS0246) : The type or namespace name ‘Eto’ could not be found (are you missing a using directive or an assembly reference?)

1 post - 1 participant

Read full topic

Viewing all 3668 articles
Browse latest View live


Latest Images

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