Grasshopper

algorithmic modeling for Rhino

Hallo Everybody,

My name is Roman and I am working on an Grasshopper PlugIn in Visual Studio 2010.

Therefore I use the Grasshopper Assembly Wizard.

For programmers my question should be very easy:

I declared a Input-Variable int A and an output Variable int B.

How can I tell my program that the Input shall be the output? Just that simple :)

See the Screenshot fpr further Explanation of the question.

Thanks for any answers,

With best regards,

Roman

Views: 1008

Attachments:

Replies to This Discussion

I think that is somethin like... (in vb)

Dim AA as new integer

DA.getData(0 <index of input>, AA)

DA.setData(0 <index of output>, AA)

You mean like this?

I get an Error that says,

"Use of a not assigned variable AA"

What did I miss?

 

Attachments:

I'm new in c# but try this.

int AA = new int();
DA.GetData(0, ref AA);
DA.SetData(0, AA);

More generally, you can use default(variableType); as first assignment.
That is the same as null for reference types, and 0, 0.0 or false for integer and Boolean types. (new) is fine here, but with reference types it is a waste (it will use new memory).

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

I did like this:

int A = new int();
int B = new int();
int C = new int();
DA.GetData(0, ref A);
DA.GetData(1, ref B);
C = A * B;
DA.SetData(0, C);

and it worked, with your help!
Thanks!

int A = 0;

int B = 0;

int C = 0;

will also work and be slightly more performant.

Thank you for the update.

Two more questions came up:

1. How do I assign a Icon for my component?

return Resources.IconForThisComponent; is described to be the right command, but I dont get it to work...

2. Is it possible to put two components (two different tools) in one File?! 

I would like to learn more about doing a good PlugIn with different features, but I didnt find a good Manuals or Handbook for the Grasshopper AssemblyWizard that helps me being more efficient...

Do you know something that provides more detailed informations here?

Thanks for any help.

Yes.

The Grasshopper SDK documentation downloadable with the _GrasshopperGetSDKDocumentation command.

To just add a new component (battery), the wizard can still help. Just use

1) Project => Add Class... => Empty Grasshopper Component from the VS top menu or
2) Right click a project or a folder in the Solution Explorer window, and choose Add => New Item => Empty Grasshopper Component

I would still advise to read the SDK documentation and a good C# programming book!

I hope this helps,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Thank you, that helps!

I will start reading :)

Have a nice evening!

Hallo everybody,

I have another question concerning the

DA.GetData() command, that should be very easy for programmers:

Can you explain how I can use DA.GetDataSet(),

is it an array?

Can I import information with GetDataSet(), is this an array

and how can I call the parts of the array?

Like:

...

for(int i =0; i<8,++i)

{

int C = 0;

C = x[i];

}

....

GetDataSet is not a method. Do you mean GetDataList?

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service