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

Windows Forms - Track bar - live update to Grasshopper component

$
0
0

@Petras wrote:

Hi,

I have a window form once I double click on the component.
On the windows form I have a track bar - "slider".

I want to pass value to component from that track bar instantly without pressing update each time.

Is it possible to do so?

I understand that to pass a value from windows form to grasshopper component, I need to write if statement for checking if dialogResult is ok or other state , that requires pressing a windows form button. But is it possible to pass a value without this if statement, or update information live? For instance once I release mouse button or when the track bar value is changed? I attached component and windows form .cs files.

Thank you very much,
Petras

    public void DisplayForm()
    {
        Utilities.CurvatureAnalysis frm = new Utilities.CurvatureAnalysis();
        Grasshopper.GUI.GH_WindowsFormUtil.CenterFormOnCursor(frm,true);

        if (frm.ShowDialog() == DialogResult.OK)
        {
            //Harvest values from form and assing them to local variables
            mPetras = frm.messageForPetras;
        }
            this.ExpireSolution(true);
    }

Component and windows forms visual studio files

Posts: 16

Participants: 2

Read full topic


Detect update/change in input geometry - c#

$
0
0

@atair wrote:

I have a list of referenced objects in GH that feed into a C# component. (they exist in the document)

Now lets say i move / rotate / edit one of the referenced objects, can my C# component detect that? How?
The idea would be that the processes inside the component at the first execution calculate for all (as it does now anyway), and only updates the modified objects?

To give a real example - I have a 'Mesh-pipe' c# component, that stores the meshes it generates, and Outputs them back into GH. Now if i move one of the input curves, i could skip all the calculations, but the one that changed.

How to do that?
Thanks!

Posts: 3

Participants: 2

Read full topic

Component with variable inputs and outputs

$
0
0

@dimcic wrote:

Hi,

I have a large experience in doing C++ plug-ins but recently I am doing some custom components for Grasshopper in C#. The programming itself is going pretty well but at the moment I don`t realize the extent to which I can customize GH components. So I will tell you what kind of component I want to create and I would appreciate if you told me if that is possible (if nothing else) so that I know I can pursue it.

I want to make a component with variable inputs and outputs. So the most general case would be:

  1. I right-click on the component and a dialog opens up
  2. In the dialog I can choose different functions, and they have different types of inputs and outputs (some have a Brep and an array of Points as an input and Curves as an output...some have an array of points as an input and as an output, etc...)
  3. After selecting the function my GH component changes its inputs and outputs according to that function...it can "transform".

So this would be some kind of "super-component" where I could spare having multiple ones for similar operations.

Is this possible?

Thanks!
Milos

Posts: 6

Participants: 5

Read full topic

List of installed Grasshopper plugins

$
0
0

@snabela wrote:

Is there a possibility to get a list of installed Grasshopper plugins (libraries) in the Grasshopper SDK? I was searching but could not find sth like that. I would need to iterate over all installed plugins and get their IDs.

Posts: 3

Participants: 2

Read full topic

rs.ConvertCurveToPolyline() and rs.RebuildCurve() issues

$
0
0

@Mertzi wrote:

Hey,
I've been trying to make a small script that converts any closed curve to a polyline, exactly as in the 'curve to polyline' component or alternatively as in the 'rebuild curve' component (I would like to add this functionality to another script later).
When I use the rs.ConvertCurveCoPolyline() method however, the input parameters which say [opt] doesn't seem to be optional. As you can see in the picture, the point count for the curve doesn't change when I move the 'tolerance slider' from .5 to 10 which it clearly should have done. If I use the min/max Edge length it works better, but that's not really what I would like to do here. What am I doing wrong here?

If I use rs.rebuildcurve instead, I get the error message: 'Runtime error (ArgumentTypeException): expected Guid, got NurbsCurve,' - how can I get the guid of a referenced curve parameter?

Thanks
/M

Posts: 3

Participants: 3

Read full topic

Grasshopper component UI naming rules

$
0
0

@timglobal wrote:

Hello forum,

I'm currently working on a plugin translation and I'm trying my best in keeping the feel of it as "native" as much as possible.

By "native" I mean the feel as if it was always there. I like plugins that are consistent with "vanilla" grasshopper, which include native icon style and proper component/input/output naming. I got used to it and it makes more sense to me, because there seems a distinct style of naming stuff in grasshopper, however under a closer look I noticed some inconsistencies. My goal is to translate it in a way that is easy to understand by our multinational community. And even though original approach has words like parameter, flatten, graft, cull and so on, and these are hard to comprehend from the beginning, later you just learn to appreciate them and don't think too much about them. Until you start to translate from another language and realize that some English names are kinda inconsistent (or, possible, I don't get it) and sometimes fails to provide strong sense.

I would like to dig deeper and figure out what's what and hopefully learn arcane art of good component naming.

When trying to find the pattern:

- "Ok, small i is for indices, cool."

- "Erm..., ok..., not always. I guess they are small on the right and capital on the left, makes sense!"

- "What?! Small on the left?! There must be another reason, I should dig deeper!"

Posts: 6

Participants: 2

Read full topic

Grasshopper 2

Compliling Components using GHPython and PyDev

$
0
0

@Miriam wrote:

Hello everyone,

I am trying to compile a test component importing PyDev code into the GHPython component. Is it possible at all? I wonder if somebody already tested it.

However, on the quest of trying it out myself, I discovered another problem. The PyDev workflow which has been working so far with Rhino 5 is not working in Rhino WIP. Did someone encounter the same problem?

For Rhino 05, I have recently configured PyDev following this:
https://www.dropbox.com/s/g6jgpvbqy7564i2/PydevRhinoGrasshopper_SetUpGuide.pdf?dl=0

In order to update the workflow to Rhino WIP, I used the new RhinoCommon.dll and RhinoCommon.xml files to make PyDev see Rhino. That seems to be working fine. However, on the RhinoPython side, I am not being able to make Rhino see PyDev. I have a --- Runtime error (ImportException): No module named ‘my module name’ --- returned. I did double check whether my Eclipse module was linked to the Rhino Python Options.

Many thanks,
Miriam

Posts: 3

Participants: 2

Read full topic


Rhino 6 WIP, Grasshopper, Python does not load os module

$
0
0

@Vladimir_Ondejcik wrote:

i just dowloaded rhino 6 wip, grasshopper pyhton componen will not load "os" module. i cant figure out why. it is in located here C:\Program Files\Rhino WIP\Plug-ins\IronPython\Lib as os.py.

error:
MissingMethod Exception, Void Microsoft.Scripting.Utils.ExceptionUtils.RemoveData(System.exception, System.Object)

As a sugestion i would appreciate is it is possible to copy errors from python copmonens as a text (directly in editor)

thanks!

Posts: 14

Participants: 5

Read full topic

Changes to GhPython UI

$
0
0

@piac wrote:

Continuing the discussion from Rhino 6 WIP, Grasshopper, Python does not load os module:

We added and modified slightly the user interface of GhPython in RhinoWIP.

@AndersDeleuran mentions:

1) I don't quite understand what the new features do (i.e. why are they there)? So I need enlightenment :slight_smile:

2) The new GHPython component appears to be slightly slower at outputting stuff to the console (just by a little, but it's enough that I notice and that it bothers me). Might be wrong though, haven't used it enough yet. Will definitely get back to you on this.

3) The ability to copy text from the output window (see above).

4) I just find it all a bit clunky and too big. As in, it's simply not as sleek and minimal as the old version. It takes up quite a bit more screen real estate (i.e. I literally have to make the new GHPython window bigger than I'd like to, to view the same amount of information as with the old one.).

Those are my immediate gripes, but also remember that I'm an old conservative fart that likes totally minimal IDE's and generally find GUI chrome and bloat totally annoying :wink:

Posts: 4

Participants: 2

Read full topic

Please help me! It's about input and output in GH Python

$
0
0

@Yuji_Kaneko wrote:

I have 2 questions...
about Question:1

I want to display that result from "a" but, always it comes from "out" , Why!?

and I don't understand what does the message from "a" mean!

about Question:2

I set an array to x and expected the result is same as Question:1 but something went wrong...

It seems the program gets only one data from array data , so it runs 5times I guess...

Question.gh (7.8 KB)

Python to Fortran dll text.txt (936 Bytes)

Posts: 4

Participants: 3

Read full topic

Please help me! my Rhino Python went something wrong!

Shortest Walk slows down with large graphs

$
0
0

@piac wrote:

Continuing the discussion from Grasshopper 2:

@Thomas_Helzle do you have a small sample of the definition that you can make public, where I can test and see where the add-on slows down? Also, if you could make a small scheme of which parameters besides Euclidean distance would help you, then I can consider what to add!

Posts: 1

Participants: 1

Read full topic

Persistent data not updated from ToolStrip Menu

$
0
0

@Guille wrote:

Hello,

I have a custom parameter to select an option from the drop down menu. This is the code:

public class gh_param_enumOption : GH_PersistentParam
{
private EventHandler OnMenuClick;

public gh_param_enumOption() : base(new GH_InstanceDescription("Option", "Option", "", "Test"))
{
    OnMenuClick += MenuItemClick;
}

public override Guid ComponentGuid
{
    get
    {
        return new Guid("94301CA0-8CCF-4B80-8C56-C23DD29D5EA2");
    }
}

public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
{
    base.AppendAdditionalMenuItems(menu);
    var names = Enum.GetNames(typeof(Test.enumOption));
    var values = Enum.GetValues(typeof(Test.enumOption));

    for (int index = 0; index < names.Length; index++)
    {
        var item = menu.Items.Add(names[index], null, OnMenuClick);
        item.Tag = values.GetValue(index);
    }
}

protected override GH_GetterResult Prompt_Plural(ref List<gh_goo_enumOption> values)
{
    return GH_GetterResult.cancel;
}

protected override GH_GetterResult Prompt_Singular(ref gh_goo_enumOption value)
{
    return GH_GetterResult.cancel;
}

private void MenuItemClick(object sender, EventArgs e)
{
    var item = (ToolStripItem)sender;
    if (item == null) return;
    PersistentData.Clear();
    Test.enumOption option = (Test.enumOption)((int)item.Tag);
    SetPersistentData(new gh_goo_enumOption(option));
}

}

The changes are not being update in Grasshopper until F5 is pressed.. Can you help me?

Posts: 3

Participants: 2

Read full topic

GH_Python compiling and Rhino 5 compatibility

$
0
0

@Miriam wrote:

Hi guys,
Components compiled on GH_Python for Rhino WIP will not load on GH for Rhino 5, correct?
Thanks,
Miriam

Posts: 3

Participants: 2

Read full topic


How do I parent a new window to the current GH document?

$
0
0

@ParamDesSing wrote:

How do I parent a new window to the current GH document, such that it opens centered on the document, and closes when the document is closed (in C#)?

This is what I have right now, but it doesn't close the window when the document, or even Grasshopper is closed (I assume because Grasshopper is just hidden):

if (_window == null || _window.IsDisposed)
{
    _window = new Window(this);

}

var owner = Grasshopper.Instances.DocumentEditor;
GH_WindowsFormUtil.CenterFormOnWindow(_opossumWindow, owner, true);
_window.Show(owner);

Posts: 5

Participants: 2

Read full topic

Launch rhino/grasshopper without displaying for optimization loop

$
0
0

@Kevin_Vidal1 wrote:

Hi everybody

It is my first topic in this forum, and I guess my first inquiry is not that straight forward!

I am currently using grasshopper to generate a parametric geometry with a set of parameter also read by an optimizer. Today the optimizer is coupled with grasshopper to generate at each optimization step a new shape. But the problem is at each step the script display the window of rhino launching grasshopper and I lose time for each opening. Moreover for a parallel optimization the optimizer will open different session leading to graphical issues. Actually i do not need to display rhino/grasshopper. It just has to read and generate automatically the geometry. Is there is a way to launch Rhino/Grasshopper in basch mode such as "rhino.exe /nodisplay /runscript = grasshopper" as command to avoid any displaying? Also maybe we can launch grasshopper without using rhino? in this is case it would be easier to perform the optimization loop without opening.

Thanks for the help,

Kevin

Posts: 4

Participants: 2

Read full topic

Continously look for changes to Rhino points with GHPython

$
0
0

@Mertzi wrote:

Hi,
I've written a script that adds a few points to the rhino active document, and the uses rs.coerce3dpoint to set the points in the gh.doc. At the moment the script runs from start to end once, adds the points first to rhino and then to the gh.doc.

I would however like this script to run a continuous loop looking for changes in the points in the rhino document, and if a change is found, replace the old list of points in the gh.doc with an updated one, making it possible to me to move them manually in the rhino viewport.

I guess this wouldn't be a problem if the points were fed to the component as a general input, but that is however not an option as the number and base location of the points are calculated from on data contained within the component.

Is there a timer or clock function or similar that I call? ...Maybe in junction with a while loop?

Posts: 3

Participants: 3

Read full topic

Baking Text

$
0
0

@Miriam wrote:

Hi Guys,

What is the equivalent to rhinoscriptsyntax.AddText() method in RhinoCommon? I am having a hard time to find it, sorry. The final aim is to extend functionality when baking text to the screen.

Many thanks,
Miriam

Posts: 7

Participants: 4

Read full topic

Listening to custom events from a Rhino plug-in in Grasshopper

$
0
0

@dave_stasiuk wrote:

I am curious as to what may be the best strategy for raising an event from a Rhino plug-in and listening for it in a Grasshopper component. The various native Rhino events work great, but I would like to know if anyone has recommendations for best practices when I use an event of my own creation (say, for example, I am passing the value of custom string DataKey from Rhino to Grasshopper).

I have created and am using a static class for this now, and it seems to work fine in nearly all cases, but I understand that this isn't a threadsafe approach, and that there are almost certainly better solutions out there.

Posts: 1

Participants: 1

Read full topic

Viewing all 3626 articles
Browse latest View live