Forgot password?

Create an account!

Forum

« back

RhinoScript – Distance between a point and a mesh

Messages

Please log in to write a message.

  • 11. xavido (Jul 19, 2010 18.29):

    Now it works!

    Yes, I had a look into Rhino help but I understood that the function only returns the face index and the point if blnReturnFaces is set True, in my case I set it False and the function should only return a single array with the point coordinates...

    Anyway, thank you again!

  • 10. Hanno (Jul 19, 2010 18.04):

    If you have a look into the RhinoScript help, you will notice that CurveMeshIntersection returns an array with the intersection point and the mesh face index. So point(0)(2) gives you the z coordinate.

    Hanno

  • 9. xavido (Jul 19, 2010 10.04):

    Thank you a lot Hanno! Now with EnableRedraw the script runs as fast as I desired.

    I knew that create the point made no sense, but it was the only way I had to get the coordinates. I went through all the manuals I had but I was not able to find a way to save the coordinates in a txt file directly from the function, because it did not work (a message error appears). I attach the script I was trying to use:

    Point = Rhino.CurveMeshIntersection(Line, Mesh, 0)
    If Not IsNull(Point) Then
       objStream.WriteLine Point(2)  'Writes Z to the text file
    End If

    The message error that appears says 'type mismatch', CurveMeshInt. is supossed to return an array but I does not work though. Could you give me a hand on that? Thanks!

  • 8. Hanno (Jul 15, 2010 13.18):

    Hi,

    two things that can speed up your script:

    1. you don't need to add the point to the model. CurveMeshIntersection already returns a 3d point, so why should you use the coordinates to add a point object and then read the coordinates again from that?

    2. while you cannot avoid adding the line, you could use Rhino.EnableRedraw to switch off model redrawing before your loop and switch it back on again. This is usually a good method to speed up scripts that need to create temporary geometry.

    Regards

    Hanno

  • 7. xavido (Jul 15, 2010 12.43):

    I finished my script, but now the problem is that it's very slow.

    My script defines around 300.000 points and then it gets the distance between them and the mesh, and this distance is saved in a txt file. I need this to generate, from the txt file, a file that contains the orders for a CNC machine to create, physically, the model I have designed.

    My algorithm is something like that:

    Do
    Addline
    Does the line intersects with the mesh? (CurveMeshIntersection)
    If yes then
    Addpoint and save the Z coordinate of the point in the txt
    Delete point and line
    End if
    Increment the coordinates of the line
    Loop

    So what it takes so long in execute is Addline and Addpoint, how could I avoid these functions and get the same result??

    Thanks!!

  • 6. xavido (Jul 06, 2010 13.36):

    You were right, Now I'm working with the last version and it works fine. Thank you very much!

  • 5. Hanno (Jul 06, 2010 12.20):

    You seem to be running an obsolete version of Rhino / RhinoScript. CurveMeshIntersection was added in SR 3 (SR 8 is current).

    Hanno

  • 4. xavido (Jul 06, 2010 12.07):

    Thanks Hanno, I've tried to use this function but it seems that it's not supported by rhinoscript, because I get an error message that says "this object does not accept the propierty or method 'Rhino.CurveMeshIntersection' "I also run the same script with an unexisting fucntion, for example: ' Rhino.invented' and I got the same error, that is why I though the function doesn't exist. Besides, Rhino.CurveMeshIntersection function does not appear in the help of Rhinoscript that comes with Rhinoceros. I'm using the integrated Script Editor of Rhinoceros.

    Am I doing something wrong?? Thanks!

  • 3. Hanno (Jul 06, 2010 10.57):

    Have a look at Rhino.CurveMeshIntersection. You can draw a temporary line like in your screenshot and intersect it with the mesh.

    Regards

    Hanno

  • 2. xavido (Jul 06, 2010 10.39):

    I wanted to say the Z axis distance, not the Y, I'm sorry.

  • 1. xavido (Jul 06, 2010 10.37):

    Hi, I'm programming a script for a project and I need to know the distance between a point, which I know its position and a mesh which it's the drawn model. I only need to know the Y axis distance. Any ideeas??

    I attach the image of my model and a line, my goal is to know which is the distance between the start of the line and the point it crosses the mesh.

    Any ideas??

    Thanks a lot!

    Distance between a point and a mesh
Recommend

Why are these buttons gray?