Grasshopper

algorithmic modeling for Rhino

Hi

I want to create a library of core functions for future scripting work in gh vb. At the studio we often use similiar classes/functions for boids,partciles,springs etc. so I would like to create a library, just to call them and not rewrite everything every new vb script. How can i do it in visual studio? I suppose it just just a matter of saving a proper.dll file but i guess i am doing something wrong.

Views: 1038

Replies to This Discussion

Aleksander,

Why not make a .gha to componentize these functions? Then could have those outputs plug in to another VB node if you so choose.

I dont know, can you tell me more how to do it?

Right - I love the GHA template for Visual Studio


Purchase extra monitor. Open this window on it while you write.

If you're testing out a new algorithm, it can be quicker for development to write it as a RhinoCommon plugin first.

Ok this i know how to do! I do it already few times. Question is how to make function to be called for every vb script component in gh

I think you're repeating your previous question.

http://www.grasshopper3d.com/forum/topics/from-visual-studio-vb-com...

A bit, because it is still not working. I compiled .dll with some example function but when i call it inside a new vb script component in gh canvas it tells me that it cannot be called. Even though i added my custom .dll into manage assemblies. What can go wrong? Maybe i have to save function in some specific way? I trieb both public and private with similair results - not working

"...it tells me that it cannot be called."

What tells you exactly?

This is the way to do it. I'm developing a dll for the next version of Peacock, to use the plugin from code, something like what you want to do, so it should run you.


Another thing, the GHA is a dll with a specific extension, so you can also compile it in gha to use it from vb script component. In this case, simply do not add any class that inherits from GH_DocumentObject (or other special objects as GH_AssemblyPriority).

1. Error (BC30451): Nie zadeklarowano elementu CreateSpiral. Może on być niedostępny z powodu jego poziomu ochrony. (line 92)

Element CreateSpiral not declared. It may unaccesible because of protection level

CreateSpiral is my test function. I just used the sample code from visual studio gh template

After adding the assembly in the component, check in "imports" region (line 4) that your assembly is properly charged. Then, write the name of the assembly and press ".", will appear all available objects. If any, such a function, do not appear, then you have to declare it public. If that are in a class also has to be public.

Just in case. You have to create a class or module to contain functions, or well, I think so now, I'm not sure.

If you want to group objects, use the namespace keyword.

Ok, did that and still... doesnt work

Class in visual studio looks like this :

Public Function CreateSpiral(plane As Plane, r0 As Double, r1 As Double, turns As Int32) As Curve
Dim l0 As New Line(plane.Origin + r0 * plane.XAxis, plane.Origin + r1 * plane.XAxis)
Dim l1 As New Line(plane.Origin - r0 * plane.XAxis, plane.Origin - r1 * plane.XAxis)

Dim p0 As Point3d() = Nothing
Dim p1 As Point3d() = Nothing

l0.ToNurbsCurve().DivideByCount(turns, True, p0)
l1.ToNurbsCurve().DivideByCount(turns, True, p1)

Dim spiral As New PolyCurve()
For i As Integer = 0 To p0.Length - 2
Dim arc0 As New Arc(p0(i), plane.YAxis, p1(i + 1))
Dim arc1 As New Arc(p1(i + 1), -plane.YAxis, p0(i + 1))

spiral.Append(arc0)
spiral.Append(arc1)
Next

Return spiral
End Function

when i type the name of assembly(class_test) and add a "." it gives only two options - class_test_info and class_test_component

As David said. You must to have something like:

Public Class NameOfClass

Public Function NameOfFunction()

End function

End class

Then, you cann write "DllName.NameOfClass.NameOfFunction()".

I think you should first of all read the basics of object-oriented programming (POO), you will not go far without that.

That's not a class, that's a function. What does the class look like?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service