Please log in to write a message.

15. pool338 (Aug 19, 2011 15.05):
Hello...i figured out how to create a point in the inner of the model, by using a bounding box.

14. pool338 (Aug 19, 2011 07.50):
How can I compute a point in the center of the model? I would need information about all 6 edges or so.

13. ledisnomad (Aug 18, 2011 16.45):
Maybe pick a point at the center of the model?

12. pool338 (Aug 18, 2011 16.01):
hi...thank u for the script.
I just wrote it down and then realized, that it can't work(?), because the plane i create is directly on the face of the model, so the distance is always 0 and therefor dist1 is always bigger than dist0 and the plane won't be flipped.

11. ledisnomad (Aug 18, 2011 15.22):
hi, pool338.
I have no idea if this works because I'd have to have the whole script and a test model, but this is the approach I would take:
'assume we have a plane from previous part of script, called strPlane
Dim arrOrigin 'Origin point of the plane, let's find it at the centroid of the plane
Dim arrPtOnModel 'Point on the model; perhaps have the user pick it?
Dim arrPtAlongNormal 'Calculate a point along the normal of the plane from the origin
Dim arrParam 'A temporary variable to get the parameter of the plane at arrOrigin
Dim dist0 'Distance from model to plane's origin
Dim dist1 'Distances from model to point along plane's normal
'Get the origin point of the plane
arrOrigin = Rhino.SurfaceAreaCentroid(strPlane)
'Get a point along the normal
arrParam = Rhino.SurfaceClosestPoint(strPlane, arrOrigin(0))
arrSrfNormal = Rhino.SurfaceNormal(strPlane, arrParam)
arrPtAlongNormal = Rhino.PointAdd(arrOrigin(0),arrSrfNormal)
'Calculate the distances
dist0 = Rhino.Distance(arrOrigin(0), arrPtOnModel)
dist1 = Rhino.Distance(arrPtAlongNormal, arrPtOnModel)
'Check the distances. If the normal of the plane points towards the model,
'dist1 will be < dist0. Otherwise, the normal points away and everythign is fine.
If (dist1 < dist0) Then Rhino.FlipSurface(strPlane)

10. pool338 (Aug 18, 2011 07.52):
@ledisnomad:
Your ideas sound good, but im really new to 3D modelling, so i dont know how to do the things u wrote.
Could u please explain them in more detail, perhaps with the rhinoscript methods?
@all:
Can i convert the generated text into polygons? I need to convert the complete model into 3DS.

9. ledisnomad (Aug 17, 2011 16.06):
Don't overconstrain it, just use 3 points. Keep it simple.
As for the normal, I'll think about it. My first thought:
 dist0 = Measure the distance from the plane's origin to the model.
 dist1 = Measure the distance from a new point copied from the plane's origin 1 unit in the direction of the plane's normal vector.
 If dist1 < dist0 Then flip the plane's normal

8. pool338 (Aug 17, 2011 15.27):
That works fine.
One question is still open:
The orientation (normal) of the plane is in wrong direction. Is it possible to change it and perhaps compute automatically on which side of the model the plane is?
I want to set the direction of the normals always away from model.

7. pool338 (Aug 17, 2011 15.10):
Thanks,
while u were writing i realized the same thing...i will now try to compute the 3rd (and perhaps 4rth) edge and try to create the plane and paste the text on it

6. ledisnomad (Aug 17, 2011 15.03):
OK, so you have to the two corners. Imagine holding a piece of paper at two opposite corners... now slowly spin it keeping those two corner points exactly where they started. There are an infinite number of planes that can be defined by those two points.
Now have a friend hold any third point on the paper. Can you turn the paper at all? No, you now have a fully defined plane.
So, you need three points to define a plane. If you have a why to choose that third point from dependent on first two, then you're all set. For example:
If:
pt1 = (x1, y1, z1)
pt2 = (x2, y2, z2)
Then you could choose:
pt3 = (x1, y2, z2)
or any combination of the pt1 and pt2 coordinates. Hope that helps!

5. pool338 (Aug 17, 2011 14.59):
Hi,
Thanks for the help. I used Rhino.PointCoordinates() to get the coordinates from the points.
But i still don't understand, why it is not possible to create a plane between two points. The Points are the upper left and the lower right corner.
I probably can compute the other corners from the coordinates of this 2 points.
A plane is only 2D (i think)...so what is missing to create it from 2 points?

4. pool338 (Aug 17, 2011 14.54):
Hi,
Thanks for the help. I used Rhino.PointCoordinates() to get the coordinates from the points.
But i still don't understand, why it is not possible to create a plane between two points. The Points are the upper left and the lower right corner.
I probably can compute the other corners from the coordinates of this 2 points.
A plane is only 2D (i think)...so what is missing to create it from 2 points?

3. ledisnomad (Aug 17, 2011 14.35):
hi, pool338.
There are a few things wrong with your script.
1. Johannes is right, you cannot build a plane from only 2 points, you need 3 points.
2. points = Rhino.SelectedObjects() will only give you the ID of the selected points, not the coordinates of those points. You'll have to use Rhino.PointCoordinates for each point.
Start with those two comments and see where you get. Come back for help often.

2. Johannes (Aug 17, 2011 14.25):
Hi, it is nor possible to build a plane between 2 points.
Take a look on the RhinoScript help  PlaneFitFromPoints and run the example using 2 and more points.
johannes

1. pool338 (Aug 17, 2011 14.20):
Hello,
I want to place some Text on a plane that i want to create via 2 Points.
The Points are points given on the model.
My code looks like this:
Rhino.Command("_SelPt")
points = Rhino.SelectedObjects()
plane = Rhino.PlaneFitFromPoints(points)
dblDX = VectorLength(plane(1))
dblDY = VectorLength(plane(2))
Rhino.AddPlaneSurface plane, dblDX, dblDY
Rhino.AddText "someText", plane
The error is, that it doesnt create the plane with the selected points.
Anyone has an idea how to fix this?
Thanks