Grasshopper

algorithmic modeling for Rhino

Err.. this one should be easy, but I don't get it...

If I import two points into a VB component, how do I create a simple line between them?
Alternatively, how can I do a line with start point, direction, length?

Thanks everyone

Mårten

Views: 2832

Replies to This Discussion

'Rhino_DotNET SDK
Dim ln As New OnLine(ptA, ptB)


where ptA and ptB are On3dPoint or IOn3dPoint.

'RhinoCommon SDK.
Dim ln As New Line(ptA, ptB)


where ptA and ptB are Point3d.


If you want to make a Line from SDL, then


'RhinoCommon SDK.
Dim dir As Vector3d = GetThisVectorFromSomewhere
dir.Unitize()
dir *= length
Dim ln As New Line(ptA, pta + dir)


--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David, I was trying the old OnLine in build 0.7.0022.
Does this mean that old VB code, like in the Primer (Second Edition), may not work in build 0.7.0022?
VB and C# code compiled against the old Rhino DotNET SDK will still run (should still run) in future version of Grasshopper. However, Rhino for Mac does not support this SDK so these 'old' scripts won't transfer once Grasshopper runs on both platforms.

Also, there is now a performance impact when using the old SDK, as geometry has to be converted from one SDK to another. It's not a huge impact, but it's there nonetheless.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Ok. I'm still a bit stuck I'm afraid. What if I wanted to rotate the line?
I'm trying:

NewLine.Rotate(angle, zaxis, ptA)

Error: 'Rotate' is not a member of 'Rhino.Geometry.Line'.

Thanks!
Mårten
Does Rotate autocomplete when you type "NewLine." ?

If you want to transform (move, scale, taper, shear, mirror, rotate) a Line, you'll have to use the Transform function. Transform has a bunch of static functions on it that allow you to specify Rotational transformations.


Dim ln As New line(A, B)
ln.Transform(Transform.Rotation(0.5 * Math.Pi, Vector3d.ZAxis, Point3d.Origin))


or... probably neater:


Dim ln As New line(A, B)
Dim X As Transform = Transform.Rotation(0.5 * Math.Pi, Vector3d.ZAxis, Point3d.Origin)
ln.Transform(X)



--
David Rutten
david@mcneel.com
Poprad, Slovakia
David:

Great stuff! Would you mind showing how to do the same "Transform" operation using the Rhino_DotNET SDK? Many thanks.

Justin
It would be something like this (off the top of my head):


Dim xform As New RMA.OpenNurbs.Transform()
xform.Rotate(0.5 * Math.PI, New On3dVector(0,0,1), New On3dPoint(0,0,0))
NewLine.Transform(xform)


--
David Rutten
david@mcneel.com
Poprad, Slovakia
David: Dumb question. Do I need to be running the .7 version of GH to have access to RhinoCommon SDK methods?
Hi Justin,

not a dumb question at all. The answer is yes. Officially RhinoCommon is only available on Rhino5, but we're shipping a special flavoured build along with Grasshopper to ensure Grasshopper can still run on Rhino4.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
"RMA.OpenNurbs.Transform" does not seem to exist... There's an "RMA.OpenNurbs.OnXform" but 'Rotate' is not a member of it.
Sorry, yes, OnXform. Does OnXform.Rotation exist?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
OnXform.Rotation...does exist! works perfectly now. (sorry, I should have more closely looked at the autocomplete.)

2 questions:
1) can you again point me to the download link for GH .7 (thought i'd bookmarked it but...)
2) Is there a library of simple examples using Rhino_DotNET SDK methods? every time I encounter snippets of code like the examples in this thread, the veil is lifted a bit more. The RhinoScript *.chm is brilliant because there is usually a simple example for each method in the help file, whereas the the Rhino_DotNET SDK is less intuitive for the uninitiated. (I suspect this will be an ongoing problem as GH lures more of us into the "deeper end" of the programing pool!)

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service