algorithmic modeling for Rhino
hi there,
i cannot find the error. Any suggestions?
Tags:
I'm no python expert, but aren't you using functions which only take a single point and then feeding it a collection of points? The image you posted only shows the first half of the error message, so it's hard to be sure what 'Point3d could not be converted' into.
--
David Rutten
david@mcneel.com
Agree with David.
Other than that you do not need rs.AddPointCloud function as it returns a single guid, not a separate guids of the points of which it has been made - meaning you could not use it later, when you want to create lines.
rs.MoveObjects function requires guid of an object, not points coordinates (line 14).
Try this one:
import rhinoscriptsyntax as rs
# pick up points
points = rs.GetPoints(False,False,"pick point cloud")
# get guids of picked points
if points:
points_id = []
for pt in points:
points_id.append(rs.AddPoint(pt))
# pick up magnet point
magnetpt = rs.GetPoint("pick magnet point")
# guid of magnet point
if magnetpt:
rs.AddPoint(magnetpt)
for i in range(len(points)):
vec = rs.VectorCreate(points[i],magnetpt)
univec=rs.VectorUnitize(vec)
newVec=rs.VectorScale(univec,3)
NewPt_id=rs.MoveObjects(points_id[i],newVec)
# get points coordinates from point guid:
NewPt = rs.PointCoordinates(NewPt_id)
line = rs.AddLine(points[i],NewPt)
i see,
i still cannot understand the differance between:
pt as a 3dpoint,
pt as a guid
pt as a list of goordinates.
Now i can get the spirit but would you like to define the differences more crearly such as to understand them further...
tnx for your time djordje
i really appreciate that!
best,
3dPoint is a type which only carries around 3 numbers; X, Y and Z.
Guid typically means that you're dealing with a Rhino point object. A Rhino point object contains (deep down) 3dPoint like data, but it also contains layer and colour information. It knows whether it belongs to any groups. how it should behave during printing. If it has a name. If it has user-strings attached to it. If it is the result of a Rhino history operation.
I'm not sure what you mean by a list of coordinates. You mean a list of Point3d structures?
--
David Rutten
david@mcneel.com
NewPt = rs.PointCoordinates(NewPt_id)
or
NewPt = [0,1,3]
i was referring to that part of the definition. But now i can understand it!
tnx David!
If you intend coding in rhinoscriptsyntax, and not RhinoCommon, you will have to supply either:
1) Guid of the object - an id by which Rhino refers to that object (for example: "3fc64e5a-29cc-4f54-b547-7c93d197ccc8")
2) a) A list or tuple, containing coordinates of a point (for example: "[2,6,0]")
b) An object of a certain type (in this case of a type Point3d). Basically under the hood of rhinoscript, your list or tuple will mostly be converted into a certain Rhino object type, but you do not have to worry about that. Doing it manually would look like this:
import rhinoscriptsyntax as rs
import utility as rhutil
pt = [2,6,0] #2)a)
pt_id = rs.AddPoint(pt) #1)
point = rhutil.coerce3dpoint(pt, True) #2)b)
print type(pt) # will result in: list
print type(pt_id) # will result in: guid
print type(point) # will result in: Point3d
So just take care if you are supplying either guid, or list(tuple)/object.
tnx!!! now it is clear!
Hi Dimitris,
I'm not expert in Python, I'm started to study it, but below you can find a Python script in GH that I've just written for your case starting from your screenshot.
code:
import rhinoscriptsyntax as rs
line= []
for i in range (pointsn):
vec= rs.VectorCreate(points, magnet)
univec= rs.VectorUnitize (vec)
newvec= rs.VectorScale (univec,-.02)
Newpt= rs.MoveObject (points, newvec)
Newline= rs.AddLine (pointz,Newpt)
line.append (Newline)
a = line
Cheers,
D
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by