When i switch the timer component interval to 20ms,this exception shows.(the reason why take photo is this exception happened in another computer)
Can any one explain that?thank you!
3 posts - 2 participants
3 posts - 2 participants
Too much boilerplate is a relative term but I don’t want to have to deal with geometric goo or anything that involves: writing classes, deriving from classes, overriding X virtual methods, etc. YUK! I’m far too lazy for that - it was fun in the 80s (no it wasn’t: it was never fun)
I’ve tried the merge component, and trees but I’m writing custom components in C# so, for me, the least effort path seems to be, Get McNeel to:
I can then do something like this:
Without bundling I might write something like this in every class that uses those parameters
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddBrepParameter("LowestDeck", "LowestDeck", "LowestDeck", GH_ParamAccess.item);
pManager.AddVectorParameter("DeckVector", "DeckVector", "DeckVector", GH_ParamAccess.item);
pManager.AddNumberParameter("OuterRadius", "OuterRadius", "OuterRadius", GH_ParamAccess.item);
pManager.AddNumberParameter("InnerRadius", "InnerRadius", "InnerRadius", GH_ParamAccess.item);
pManager.AddNumberParameter("PipeRadius", "PipeRadius", "PipeRadius", GH_ParamAccess.item);
pManager.AddNumberParameter("ArcCornerRadius", "ArcCornerRadius", "ArcCornerRadius", GH_ParamAccess.item);
pManager.AddNumberParameter("TriangleBaseRadius", "TriangleBaseRadius", "TriangleBaseRadius", GH_ParamAccess.item);
pManager.AddNumberParameter("PadOuterRadius", "PadOuterRadius", "PadOuterRadius", GH_ParamAccess.item);
pManager.AddNumberParameter("PadInnerRadius", "PadInnerRadius", "PadInnerRadius", GH_ParamAccess.item);
pManager.AddNumberParameter("DoorStepRadius", "DoorStepRadius", "DoorStepRadius", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
Brep LowestDeck = null;
Vector3d DeckVector = new Vector3d();
double innerRadiusNumber = 0;
double outerRadiusNumber = 0;
double pipeRadiusNumber = 0;
double arcCornerRadiusNumber = 0;
double triangleBaseRadiusNumber = 0;
double padInnerRadiusNumber = 0;
double padOuterRadiusNumber = 0;
double doorStepRadiusNumber = 0;
{
int inputIndex = 0;
DA.GetData<Brep>(inputIndex++, ref LowestDeck);
DA.GetData<Vector3d>(inputIndex++, ref DeckVector);
DA.GetData<double>(inputIndex++, ref outerRadiusNumber );
DA.GetData<double>(inputIndex++, ref innerRadiusNumber);
DA.GetData<double>(inputIndex++, ref pipeRadiusNumber );
DA.GetData<double>(inputIndex++, ref arcCornerRadiusNumber );
DA.GetData<double>(inputIndex++, ref triangleBaseRadiusNumber);
DA.GetData<double>(inputIndex++, ref padOuterRadiusNumber );
DA.GetData<double>(inputIndex++, ref padInnerRadiusNumber);
DA.GetData<double>(inputIndex++, ref doorStepRadiusNumber );
}
With bundling I could write:
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddBrepParameter("LowestDeck", "LowestDeck", "LowestDeck", GH_ParamAccess.item);
pManager.AddVectorParameter("DeckVector", "DeckVector", "DeckVector", GH_ParamAccess.item);
pManager.AddDataAccessParameter("KP", "KeyParameters", "Bundled Key Parameters", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
Brep LowestDeck = null;
Vector3d DeckVector = new Vector3d();
double innerRadiusNumber = 0;
double outerRadiusNumber = 0;
double pipeRadiusNumber = 0;
double arcCornerRadiusNumber = 0;
double triangleBaseRadiusNumber = 0;
double padInnerRadiusNumber = 0;
double padOuterRadiusNumber = 0;
double doorStepRadiusNumber = 0;
DA.GetData<Brep>(0, ref LowestDeck);
DA.GetData<Vector3d>(1, ref DeckVector);
{
IGH_DataAccess keyDA = null;
DA.GetData<IGH_DataAccess>(2, ref keyDA);
int inputIndex = 0;
keyDA.GetData<double>(inputIndex++, ref outerRadiusNumber );
keyDA.GetData<double>(inputIndex++, ref innerRadiusNumber);
keyDA.GetData<double>(inputIndex++, ref pipeRadiusNumber );
keyDA.GetData<double>(inputIndex++, ref arcCornerRadiusNumber );
keyDA.GetData<double>(inputIndex++, ref triangleBaseRadiusNumber);
keyDA.GetData<double>(inputIndex++, ref padOuterRadiusNumber );
keyDA.GetData<double>(inputIndex++, ref padInnerRadiusNumber);
keyDA.GetData<double>(inputIndex++, ref doorStepRadiusNumber );
}
For me the code is almost the same with or without parameter bundling. I could start off without it and then convert to bundling if I think it’s worth it.
It has no more boilerplate than not using bundling.
1 post - 1 participant
Hello, dear Community,
I am developing a small assembly to automate the generation of pdfs straight out of Grasshopper.
Working on it, I have noticed that Grasshopper, while Rhino is in Layout mode, bakes its geometries not to the ModelSpace, but to the PageSpace:
Since the users of my component will likely run it while checking their page Layouts, I needed some sort of workaround to prevent that.
What I came up with, simply, is forcing Rhino to switch back and forth during the component execution between Standard and Page Views.
To replicate the bug:
Is there any way I can force Gh to ‘reboot’ the canvas after that line of code?
Thank you very much for your time looking into this.
1 post - 1 participant
Hi all,
I can’t find a suiting methode for removing an item on a specific branch.
Am I missing something, how could I do it?
Thanks everybody!
7 posts - 2 participants
Hello all,
I am a beginner in learning C# in Grasshopper and maybe you could clear this particular doubt for me.
Whenever I try to code a new list, right after closing the function and inserting the open parenthesis, The function is translated into something known as Light.
I am attaching the pictures below.
Thank You.
5 posts - 3 participants
I am using split list to pick a coordinate out a list (in this case 2). I then use this point with some others ad vertices in a polyline.
The issue is that split list takes in data of the form {0;0} and outputs it as {0;0;0}. I can obviously flatten it but how can I remove the middle branch / avoid ‘split list’ doing this to the data? I can solve this but I want to understand why the component is doing this as I don’t see the need. The attached image should illustrate this.
5 posts - 2 participants
Hello, I was wondering if there is a way to programatically (C#) collect the numeric data from a given input? For example, you can obtain an input source’s nickname using the following expression:
this.Component.Params.Input[0].Sources[0].NickName
Is there a way to do something like this?
this.Component.Params.Input[0].Sources[0].Value?
I realize that it’s probably not that simple since the input components could be of different types (see image below) but I was wondering if there was a general way to (1) determine if the input value is a number, and (2) if so, what’s its value? Can someone point me in the right direction?
7 posts - 4 participants
i am writting a video component to output bitmap,i wrote like this:
protected override void SolveInstance(IGH_DataAccess DA)
{
..........
vs.NewFrame+=new NewFrameEventHandler(v_newframe);
...........
}
private void v_newframe(object sender, NewFrameEventArgs eventArgs)
{
..............
while (ghdoc.SolutionState != GH_ProcessStep.PostProcess || ghdoc.SolutionDepth != 0)
{ }
var caller = new GH_Document.GH_ScheduleDelegate(update);
Grasshopper.Instances.ActiveCanvas.Document.ScheduleSolution(1, caller);
}
private void update(GH_Document gh)
{
ExpireSolution(false);
}
When this component run,when the NewFrame event is called,the code in callback function will update compoent.
it works fine ,But, when i run 2 of this compoent in a doc in one time for a several minutes ,an error shows:
i guess it must be relate with schedulesolution,but i donnot know how to fix this ,thank you for help!
1 post - 1 participant
Hello everyone,
So I managed to pack rectangles the way I need using kangaroo 2.
however I cannot manage to have 0 gaps it just screw up with the code.
I am trying to script a c# code that would remove the gaps between the rectangles.
so that they form one region if I do a region union.
If anyone can help me with this I would be really thankful.
1 post - 1 participant
Hey guys,
Rhino 7 provides new method called Headless to create a new RhinoDoc, by the way brilliant!
In order to import a .dxf inside rhino using C#:
if (run)
{
using( var doc = Rhino.RhinoDoc.CreateHeadless(null) )
{
doc.Import(path);
var geometryList = new System.Collections.Generic.List<GeometryBase>();
var names = new System.Collections.Generic.List<string>();
foreach(var obj in doc.Objects)
{
geometryList.Add(obj.Geometry.Duplicate());
var layer = doc.Layers[obj.Attributes.LayerIndex];
names.Add(layer.FullPath);
}
geometry = geometryList;
layerNames = names;
}
}
Is it a bug because of WIP or something else?
Thank you!
F
ImportC#.3dm (38.8 KB)
ImportC#.gh (9.6 KB)
TestFile.dxf (117.4 KB)
1 post - 1 participant
Hi all, I am trying to use the C# Scrip editor in Grasshopper on Rhino6 for Mac.
Two things I noticed coming from windows:
1 post - 1 participant
(topic withdrawn by author, will be automatically deleted in 24 hours unless flagged)
1 post - 1 participant
I’m trying to peek inside a grasshopper file and grab some simple data, for example text from a panel that I know is there with a specific nickname.
My problem is that IF i try to look into a file that contains a component for a currently-uninstalled plugin then all the methods i’ve tried (either via GH_IO/GH_Archive OR GH_DocumentIO) then I get the standard popup dialogue:
The commands I’m trying are either:
var archive = new GH_Archive();
archive.ReadFromFile(path);
var doc = new GH_Document();
archive.ExtractObject(doc, “Definition”); - this triggers the dialogue
OR
GH_DocumentIO docIO = new GH_DocumentIO();
docIO.Open(path); - this triggers the dialogue
Ideally I’d avoid this. i.e. the document or archive would just load without missing components as if I clicked “close” on the popup dialogue. Is there a way to do that? Any advice very much appreciated! Currently working with Rhino6.
1 post - 1 participant
Hi all, @DavidRutten,
For some reason, the Write() method in my gh types (inheriting GH_Goo) are never called. I don’t know what’s going on.
I have custom parameters and types inheriting from GH_PersistentParam< T> and GH_Goo< T> that are abstract classes (Param_Base and Goo_Base) and also other classes that inherit these. The abstract classes override the Write() and Read() methods just to check if they are being called, like this:
In the param:
public override bool Write(GH_IWriter writer)
{
RhinoApp.WriteLine("Write Param_Base"); // this returns as expected
foreach (var d in PersistentData.FlattenData())
Rhino.RhinoApp.WriteLine(d.ToString()); // this returns as expected, all data is there
return base.Write(writer);
}
In the goo:
public override bool Write(GH_IWriter writer)
{
RhinoApp.WriteLine("Write Goo_Base"); // this call never happens!
return base.Write(writer);
}
The non-abstract classes doesn’t implement this methods. For some reason, Goo_Base.Write() is never called.
I check a .ghx file and its chunk is missing the data of the values:
<chunk name="PersistentData">
<items count="1">
<item name="Count" type_name="gh_int32" type_code="3">1</item>
</items>
<chunks count="1">
<chunk name="Branch" index="0">
<items count="2">
<item name="Count" type_name="gh_int32" type_code="3">1</item>
<item name="Path" type_name="gh_string" type_code="10">{0}</item>
</items>
</chunk>
</chunks>
</chunk>
This is the third time I’ve tried to fix this, I need help, I don’t know what could be going wrong. Another strange thing is that the Extract Parameter doesn’t work, it doesn’t do anything.
Hierarchy of inheritance:
Param_Base< T> : GH_PersistentParam< T>
Param_Foo : Param_Base< Goo_Foo>
Goo_Base< T> : GH_Goo< T>
Goo_Foo : Goo_Base< Foo>
I’ve done this a thousand times and it worked, and it’s too much code to turn everything upside down to look for the error, so I need to understand better why the parameter Write method doesn’t call the goo Write method, PersistentData has values.
Please help.
5 posts - 3 participants
Hi guys,
I just thought in sharing some work I have been doing on and off, unfortunately close to the time Rhino.Inside was about to release. I was working on an interoperability application as well, for now my plugin is hosted by Dynamo and Grasshopper. It has been mostly just for fun, but I am not sure if I should keep developing it any further as a serious project.
Here are some videos.
Feel free to write any type of comments
Cheers!
1 post - 1 participant
Hi all! My name is Sergio and I’m new into Python and Grasshopper. Im trying to develop some useful tools via Python and I didn’t found yet the solution to this problem:
I made a GhPythonScript wich changes and updates values on a ValueList when it gets plugged into the component. I used this to navigate on the inputs of the Script:
ghenv.Component.Params.Input[1].Sources[0].Name = "List1"
ghenv.Component.Params.Input[1].Sources[0].NickName = "List1"
ghenv.Component.Params.Input[1].Sources[0].ListItems.Clear()
1 post - 1 participant
Hi All, I have searched up and down and can’t seem to find the source code for a very, very simple Value List component in C#. All I’m trying to do is give a predefined list of 5 possible single letter string values and let the user pick just 1 to feed into a component. I have found more sophisticated examples, such as @andheum’s from Human UI (and thanks for sharing the source code, Andrew!). But since I’m just starting out with these kinds of objects, maybe others would benefit from seeing a minimal example, as well.
Thanks in advance!
3 posts - 2 participants
Hello,
I need to iteratively start a doc.NewSolution for an optimization but I need to wait for the new solution to finish executing before resuming my program, or the new solutions will start to get all mixed up. I was wondering what would be the best way to achieve that? I’m having some trouble understanding how the new solution process works and how to handle that… Any advice will be incredibly helpful.
Thanks,
Sofia
6 posts - 3 participants
On april 19 2013 @DavidRutten was mentioning
We’re still working on making it possible to install a GHA without an RHP using *.rhi, hopefully more news on that soon.
If you can get away with not using some heavy-weight installer package like Wise or MSI, we recommend switching to RHI.
I’ve been trying to package a grasshopper only plugin VoxelTools-1.0.14.rhi, this did not seem to work with the error message:
I could not find any follow up from McNeel, other than David’s message, so possibly this error means that grasshopper only is not yet possible.
Has there been any follow up, or is the development *.(mac)rhi system abandoned in favor of yak?
2 posts - 2 participants
Hi,
I’m looking for strategies that would enable me to use C++ code in Grasshopper.
I’m not interested in compiling other peoples’ libraries, but I’ve recently started learning C++ and now I want to harness some of this power for my GH projects. Also, I’m a macOS user!!
I have no idea how this could work! Do I need to use Python (or C#) as an intermediary to load some compiled library or header?
On Windows, you compile DLLs, what would be the macOS equivalent?
Any ideas guys? It this even possible for mac users?
Any pointers to where to start are welcome (pun intended).
Thanks.
4 posts - 3 participants