How do you draw a spline perpendicular from a surface?

I have asked this question before and I am still not sure how to do it.

 

I have two surfaces at any angle.  I want to be able to draw a spline that starts perpendicular from one surface and ends perpendicular to the second.  How would you do this?

My solution has been to draw a short straight line segment from each of the surfaces and then span the line ends with the spline.  I also have not figured out how to make the spline then be tangent to the short line segments.  Any help with that question, would be great also.

 

Thanks,

P

Views: 2757

Replies to This Discussion

Good question.  This points to a slight lack in the command options for creating splines in Rhino.  InterpolateCrv has options for StartTangent/EndTangent, but there is no way to get a direct normal to a surface with that.

Currently the solution is to create some quick construction geometry using Line>Normal on each surface where  you want the curve to start/end, then use the line segments as guide geometry to create your spline.

For a control point curve, the tangent lies along the line between the two last control points of the curve.  So if you wanted to construct a control point curve, again, you could use the lines created above to snap the first, second / next to last and last control points to.

Lastly, you could use the lines>normal as above, but make the lines go to the inside of the surface (the opposite normal), then use BlendCrv between the two line segments.  The result will be tangent to the surfaces.

However, it would be good if Interpolate curve Start/End tangents had a surface normal option added; also that BlendCrv could have a "NormalToSrf" option.

----H

H,

This seems to be a good solution.  I can work with that.  It is a bit clumsy but it achieves the results I want.  Thank you.

 

Chirs,

Great Illustration.  This was very helpful.  Thanks.

 

Back in the days of AutoCAD (for me that was 15 years ago) we were able to give a conditional "To" statement to the end of the line.  This would allow you to start a line tangent to a circle and end perpendicular to a line.  It would be nice if Rhino could let you do this to.

This kind of thing can usually be done with scripting. 

There is a command called '_Conic' that does what you're describing regarding the start/tangent-end/perpendicular method.

Here is a hacked together scripted implementation that uses the Rhino command BlendCrv.  Note that once the curve has been created, before you hit Enter to accept, you can still adjust it while inside the BlendCrv command.  The script assumes that the curve will start in the positive surface normal direction from the pick point, you can however, adjust either end in command with the "Flip" option on the command line.

----H

Attachments:

H,

Thanks for the script, this is just what I needed.  I don't know how to use it yet but it is an example of where I'd like my CAD skills to go.  I will use this as a jumping off point for learning scripting.

 

Do you know of a good source for learning scripting?  Is scripting a more controlable way to drive CAD than say Grasshopper?  or, are they just different approches?

P

I don't know how to use it yet

To run one of my scripts in Rhino, the easiest is to put it in a toolbar button. Open the script in a text editor. Create a new button in Rhino somewhere, then open the button editor and type the following into the edit box:

! _NoEcho _-Runscript (

<copy the script from the text editor and paste the entire script text here>

)

Don't forget the close parentheses at the end after the script.

Hit OK to create your button, once done it will run the script when you click.

Do you know of a good source for learning scripting?

There are some good gettng started points here. The Rhinoscript primer is a good place to start there are also lots of tutorials on the net.

Is scripting a more controlable way to drive CAD than say Grasshopper?  or, are they just different approches?

Different approaches, and overlapping.  There are some things you can do in GH that are very complex or difficult to do with scripting and there are things you can do with scripting that you can't do at all in GH.  There are also lots of things that you can do with both.

Grasshopper needs its separate window and the geometry is all virtual until you bake it, scripts is (can be) completely integrated into your workspace (no need to have a separate window, you can make toolbar buttons or aliases with them) and the geometry you create is automatically added to the file.  You can access and change a lot of Rhino options with scripting, not with GH. Grasshopper is dynamic, scripts are static.

For me, who works more in an analytic mode with existing files coming from other people, scripting is more useful - I have developer hundreds of my own specialized tools and they are integrated into my workspace.  For others GH is more useful, especially when doing generative/interactive design.

GH is undoubtedly easier to approach with its visual, game-like interface and its incredibly well pre-programmed modules, scripting is more rigorous and demanding, like learning any language...

----H

H,

I'll give your code a try this evening and let you know if I ran into any problems.

 

Thanks,

Peter

When you open the Rhinoscript editor this is what you see.  On the left you have expanding folders that contain the Rhinoscript methods that are available.  On the right is the editing window with the basic syntax in place to start a script.  A simple script usually only needs to be written in one sub-procedure called Main().

If you expand the Curve Methods folder on the left you'll see all of the methods associated with curves. 

If you double click on the Add Circle method a help file will open.  There is a help file available for every method.  The file tells you what the method does, the proper syntax for the method, the parameters of the method and whether they're required or optional parameters and what the method returns.   It also gives you an example script that uses the method as well as links to some related methods.

Here I've copied and pasted the example for the Add Circle method into the editor window between the Sub and End Sub keywords.  The Add Circle method also uses the WorldXYPlane method as a parameter input.  The WorldXYPlane method returns the world xy plane which is stored in the variable arrPlane.  Notice also that the arrPlane variable is declared before it is used with the Dim keyword.  The parameter input for Rhino.AddCircle then becomes 'arrPlane' and the value '5.0' for the radius.

To make it a little more interesting I've declared two new variables, strCircle and dblRadius, with the Dim keyword.  Then I repeated the AddCircle method but this time I've assigned the string identifier that the method returns to the variable strCircle.  This will allow me to use the circle object created at a future point in the script.  I've also assigned the radius to a variable dblRadius.  This gives me some flexibility to assign different values to the radius without having to enter it directly into the AddCircle method each time I wish to change it.  Notice also that I've had to enclose the parameters of the second instance of AddCircle method with parentheses because I've chosen to assign the return value of the method to a variable.  In the first instance of the AddCircle method the return value is not assigned.  The syntax in that case is to not use parentheses.  If you now click on the 'Run script' icon up by the 'Source' menu item the script will create two circles and put them into the Rhino document.

The point of showing this is to indicate that a very good source of learning material is right in the editor itself in the examples contained in the help files.  Additionally it's a good idea to have a generic VBscript reference book.  To get into the depth of Rhinoscript you have to understand how arrays work and how to fill an array dynamically with the 'Redim Preserve' keywords.  You also need to understand how to work with conditional statements and loops; If...Then; For...Next; For...Each...Next.  From the geometry side it's good to understand how parameter space works for curves and surfaces and how vectors are defined and what the vector operations are.  Another important part on the code side is error trapping.  Without it a script will easily hang up on you and break the better workflow it was intended to create.  If you take Rhinoscript in small doses I don't think you'll find it terribly difficult to learn.  Be sure to ask questions if and when you get stumped.  There are a few idiosyncrasies within some of the methods that can bring you to a halt and you'll probably never figure them out on you own. A question or two in one of the forums or the newsgroup will usually get you back in motion.

Chris,

Thanks for the excelent introduction to Rhino Scripting.  I have not had time to look for it, so I'll just ask, is Rhion Scripts an add-in or is it within Rhino 5.0?

 

I had noticed it looked like VBA, I am glad that it is based on VB, I understand that language a bit.

 

I think I'll make this my evening hobby for a while.

 

Peter

The Rhinoscript editor is built-in in Rhino 5.  You'll find it at Tools>Rhinoscript>Edit.  If you already understand VB then you shouldn't have any trouble with coding Rhinoscript which is based on VBScript.

Rhinoscript is based on vbScript (not VB) they are two different animals, although the syntax is similar in a lot of cases.  VBScript is quite a bit easier and but less powerful - however for most Rhinoscripting tasks it's more than adequate.

There is also the possibility to script in Python in Rhino 5 - more powerful than VBScript, but perhaps a bit more complex.  Python scripts can run on MacRino, VBScript not.  Python for Rhino development is still in it's infancy, some of the Rhinoscript methods are not included yet.

Both Rhinoscript based on VBScript as well as Python are native in Rhino 5.  To get the Rhinoscript editor, type EditScript.  To get the Python editor, type EditPythonScript.

----H

RSS

Translate

© 2014   Created by McNeel Admin.

Badges  |  Report an Issue  |  Terms of Service