Grasshopper

algorithmic modeling for Rhino

I am trying to move a point in python. I tried newpoint=mypoint.translate(myvector) and it did not work. It does not matter to me if it moves mypoint or copies mypoint to the new position (but i'd like to know how to do both).

In general, are transformation commands different than commands like evaluate and split? My experience with python has mostly involved commands like "Rhino.Geometry.BrepFace.Split(myface,mycurve,.001)" where the objects executed upon are within the parenthesis.

Views: 5796

Replies to This Discussion

 "Hi Lawrence Yun

       Check the attached files."

Attachments:

Thanks

So xform defines the transformation and then I have to use scriptcontext.doc.objects.Transform() to actually move the point. And this will work for all other transformations (rotate,mirror,scale) as long as I set up xform correctly? 

One problem I am having is that my point does not have a Guid. I noticed that you set the type hint for your point input to ghdoc object. The points I am trying to move originates from inside the python script. Is there anyway I can give it a Guid? Or maybe there is another way to move it? What I don't want to do is to generate it in the Rhino window and then delete it. There has got to be an easier way to move objects.

My script is a short one (just a test) where I have a point on a mesh and repeatedly copy it along the mesh to create a polyline that flows on the mesh.

Attachments:

Check the attached files

Attachments:

Thanks.

So no matter what, for me to transform geometry, it must be Rhino geometry. And "coerce" turns my grasshopper/python generated geometry into Rhino geometry.Why is it still necessary to "AddPoint" after the point has already been "coerced"?

You could also just add the point with a translation vector, like so:

import Rhino as rc

# Make point and vector
myPoint = rc.Geometry.Point3d(0,0,0)
myVector = rc.Geometry.Vector3d(1,1,0)

#"Move" point
myPoint = myPoint + myVector

Does this work for other geometry? Like curves and breps?

Afraid not, it is taking advantage of vector math shorthand syntax. For any geometry type you can however use the transform method with a translation transform.

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