generative modeling for Rhino
Hello, somethings I still dont understand...
What 'is not working?
Private Sub RunScript(ByVal pt_1 As Point3d, ByVal pt_2 As Point3d, ByRef A As Object)
A = Rhino.Geometry.Point3d.DistanceTo(Pt_1, Pt_2)
DistanceTo() is a method available from any Point3d you might have. It is not a static (Shared in VB) method which is available via the type-name. It would have been called DistanceBetween() if it required two inputs.
The difference between shared and non-shared method is that shared methods should be called with the class name as a prefix. For example:
Origin is a shared property on the Point3d struct. I.e. you do not need an existing point to get the world origin location. DistanceTo() is a non-shared method that operates on the instance of the point you're calling it on. The signature of DistanceTo() requires a single point as an input parameter, so when you're shoving both Pt_1 and Pt_2 into that function it is going to choke.
This in itself is already a bit of a give-away. DistanceTo() clearly computes the distance between two points, but it only accepts a single input. That must mean that the function should be called on the second point in this drama.
is what you're looking for.
The big advantage of Shared methods over Non-Shared methods is that you do not need an instance of a type to call the method. It is always available, where ever you are and whatever data you might have at your disposal. All RhinoScript methods are Shared in this respect.
The big advantage of Non-Shared methods over Shared methods is that you can get away with a smaller signature. You are calling the method on a specific object, which reduces the amount of code you have to type. I.e.
is shorter than
I would like to know why the command can not be used with C# as per attached file.
DistanceTo() is a member of Point3d. Since you haven't assigned a type-hint to your variables they come in as System.Object.
When I open your file, I get the same answer out of all 4 components. What happens when you close and then open that file?
VB is a more forgiving language than C#. It will accept certain mistakes in capitalization, brackets as well as the odd type mismatch.
Yes, it works after closed and reopened.
Why I dont need to put Rhino.Geometry....before?
Rhino and Rhino.Geometry are namespaces. A namespace is just like a folder in Windows Explorer. The classes are like the files, and all files are located in some folder.
If you import a namespace into a source code file then you do not need to include these prefixes before you use a class name. Look at the top of the file, if there's a statement like:
then that means you can leave out the "Rhino.Geometry." part for classes that are part of that namespace (such as Curve, Point3d, or Plane for example)