Grasshopper

algorithmic modeling for Rhino

i write:

  Private Sub RunScript(ByVal x As Curve, ByVal y As Vector3d, ByRef A As Object)
    Dim movex As New OnXform
    movex.rotation(0.5, y, Point3d.Origin)
    x.Transform(movex)
    A = x
  End Sub

the results is red....it doesnot work...output is Error: Type 'OnXform' is not defined. (line 86)

i think may be it is replaced by another class....who knows it?

thank you very much!~

Views: 627

Replies to This Discussion

Hi Andrea,

OnXform is a class in the old Rhino SDK. Since you're using RhinoCommon now, the class you're looking for is called Transform. It's in the Rhino.Geometry namespace.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

thank you David

but how can i make a instance of this structure?i try many times,but failed....

To translate the code you have above, you'd need something like this:

Dim movex = Transform.Rotation(0.5,y,Point3d.Origin)

x.Transform(movex)

A = x

Thank you Andrew,and i add C# edition:

  private void RunScript(Curve x, ref object A)
  {
    Transform movex = Transform.Rotation(0.5, Vector3d.ZAxis, Point3d.Origin);
    x.Transform(movex);
    A = x;
  }

  Private Sub RunScript(ByVal x As Curve, ByRef A As Object)
    Dim movex As Transform = Transform.Rotation(20 * Math.PI / 180, Vector3d.ZAxis, Point3d.Origin)
    x.Transform(movex)
    A = x
  End Sub

//add As transform can avoid warning

Or, shorter still

x.Transform(Transform.Rotation(0.5, y, Point3d.Origin))

Creating a specific variable for a transform matrix is only really useful if you need it more than once.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

yes,it is shorter!

David,can you explain the matrix of transform?because it is difficult to understand.....what is the meaning of m00,m01,m02...........

Thank you

A transform matrix is a 4x4 grid of numbers where each number has a specific meaning assigned to it. Some of them are to do with translation, others with rotation, others still with scaling and tapering. The beauty of using matrices to encode transformations is that you can combine them before you apply them. It is quite a lot of work to transform a Brep, so you really only want to do it once. With transforms you can take 3 translations, 2 rotations and a scaling step, put them all in a single matrix and then only modify the Brep once.

You should not have to concern yourself with the actual meaning of the elements in the matrix, just use the provided functions to create standard transformations.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

thankyou David,for long and clear explaination!i know what i should do is to ignore matrix:),because we can use the translate and rotation,scale method instead.

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