Hi everyone,Glad to be starting out taking part in the rollout of Rhino for Mac. I’ve recently purchased the commerical build (5.1) and am happy with how things work for regular modeling and my past usage as a Windows operator.The biggest missing feature for what I’d like to do in Rhino is to import airfoil sections. I used to rely heavily on this rhinoscript and database:Where to start? I see that Python is being put forward and McNeel is hoping to get folks making cross-platform suppported scripts and plugins functioning.I am not a programmer, though looking at the old Rhino script, it seems like it ran a fairly simple set of functions to loft curves through the imported points and then close that into a single curve.
![]()
Running a Python script. To get acquainted with how Python scripts can help you model first run some of the sample scripts that are provided. In the Command prompt edit box (top left by default) type the RunPythonScript command. If it’s the first time you run this command the dialog box that comes up will show the files in the samples directory. Using Python. Welcome to the Rhino 6 version of this page! Looking for the newer Rhino 7 WIP version? Rhino Developer Docs. Guides API Samples Videos Forums. Rhino.Python Guides Quickly add functionality to Rhino or automate repetitive tasks. What is Rhino.Python? Getting Started. Your First Python Script in Rhino (Windows, Mac.
![]()
It worked well enough for my hobby-use of RC plane design up to giant scale model wings.Can someone please give me specific directions on how I may begin the process of getting this script ported over to Rhino for Mac? Sadly, I do need a bit of hand-holding here as I have not programmed since the late 1980s.Thank you so much for your help,Carl. Hi Carl,Glancing over the script, it’s indeed not complex at all. I myself have no spare time at hand to help you out, but I reply to maybe provide an incentive for others to give it a go and help you out:The python script functionality and workflow outline:1: browse for file.dat file (provided in zip package)2: read the file with: name in the first line and next lines ascii XY coordinates to be converted to 3D points3: Create and add to the document an interpolated curve through these 3D pointsHTH-Willem.
Yeah, I would have looked at it today, but I have a mill job to get out, if nobody has responded I can look tomorrowEdit: you can have a go with the following, it’s my first try at airfoils. I noted on testing a few sections that the points don’t always result in nice, smooth curves The script below will try to import.dat files in either Lednicer or Selig formats (slightly different) and will add the curves plus the points for reference. Selig should be all one curve if I understood correctly, Lednicer will be 2 (upper and lower).
The curves are named after the file name.Let me know if it errors out somewhere, the file format doesn’t seem to be all that consistent. I hacked this together rather quickly; I didn’t put a lot of comments in the script. If you need more explanations, please ask–Mitch(1.6 KB). Wow, fantastic!Thank you so much for drafting that. I have been playing with figuring out how to get Rhino to parse the script so that what jodyc111 noticed doesn’t happen; some of the.dat point files loft curves that are not fair between points, particularly around the leading edge (the front) of the wing sections. Even common NACA00-series files are getting messed up.I found a setting in the new Rhino curve tools that fixes part of this problem. Since your script also keeps the points in the generated object, it was easy for me to experiment.
Here is what I found:Rhino interpolates perfect curves when the Knots selection is set to Chord.This is great, and I think that with some reading I can figure out how to fine tune the option to do so. I understand your python script, though I do not know how to to write it. What I will seek to add are two primary functions, and to ask one of the community:.Adding the Knot: Chord function to the script to see if that works in automation as it does when building a curve manually through the points.2.Adding a dialogue that asks how many units in the open model that the coordinates can be scaled to, ex: can it be one major line in the grid, a linear dimension such as, “100mm”, or is this a limitation of the language and how Rhino is able to parse.dat files? I ask because the old script for Windows also only lofted the airfoils into one unit of length, no matter what your file preferences were set to. That leads to always having to scale your wing up to the desired size post import, and can do funny things with tolerances if minor grid lines are microscopic.Can I pin the RunRhinoScript‘this script that Helvetosaur is making’, to the user interface? It of course is showing up in the right-click menu after I found the command and ran it the first time, though I’d like to make it a standard icon or tool menu entry.
Any help there is great, and I’ve not delved into the new UI deep enough to see what is presently possible.Very excited to see how this progresses, and it’s already usable so a huge thank you for taking the time to look into the problem and to write the code.(62.7 KB)Have a great day,Carl. CMD:Rhino interpolates perfect curves when the Knots selection is set to Chord.This can be programmed in the script, there are options for Uniform, Chord and SqrtChord as in the normal Rhino command. However, I did not find this helped in all cases. In the points file below (taken from a 737 wing profile), no matter which one of the 3 options is chosen, there is still a “bump” in the lower leading edge area. I marked the offending points in orange/red. Wim:The coordinates in those files are identical (though organized a bit differently - the AirConics one is not divided in an upper and lower profile and the upper coordinates are in the reversed order and missing the first row).File formats do seem to vary a bit According to, there are two main formats, Lednicer and Selig. It would seem that your format is Selig if there is only one profile I didn’t specifically parse the header to differentiate between the two, I used the fact that there should be a blank line between the two sets of coordinates in Lednicer.
But maybe that’s not always the case, I should probably re-write it to be more rigorous.–Mitch. Yes, that appears to be the difference between those two files.From For reference, the original airfoils in the list and new ones added by Selig are in an x,y format starting from trailing edge, along the upper surface to the leading edge and back around the lower surface to trailing edge.
Lednicer’s contributions are upper surface points leading edge to trailing edge and then lower surface leading edge to trailing edge.I suppose that a script should read both upper and lower surface in a Lednicer-formatted file. Helvetosaur:I will create a new version with some more options:Option to choose Uniform, Chord, or SqrtChord as interpolation typeX axis length scale (.dat files are always 0 to 1 in X)Fantastic! This should be more than enough to get hobby designers such as myself rolling with the new build, though I’m honestly surprised that more naval architects and aerodynamicists haven’t recompiled a script like this. Well, either way it will be a great boon to the community. Thanks so much again for putting your efforts into making it work, and also for the inspiration re: seeing what can be done with learning a little bit of code.
This is really quite cool. Helvetosaur:As far as running it in Mac Rhino, the easiest way is via an alias.Here’s how to install a script in Mac Rhino and set it up to run from an alias:Download the script file and move it to the following folder:/Library/Application Support/McNeel/Rhinoceros/ScriptsThis is a hidden folder, to navigate to it, press and hold the Alt key and pull down the “Go” menu, you will see “Library” - navigate to the Scripts folder along the above path from there. For ease of use the next time, make a shortcut to the scripts folder on your desktop.In PreferencesAliases, create a new alias - call it anything you want- and in the right-hand path box next to the alias, copy and paste the following:! -RunPythonScript “ScriptFileName”Where ScriptFileName is the name of the file you just copied to the scripts folder. Do enclose the name in quotes if the filename has spaces in it, even if not, it will not harm to have them.That’s it, whenever you type the alias, the script will run. You should see it autocomplete even after typing just the first couple of letters.Oh, that’s clever. Again you have my thanks.
Looking forward to playing with the next iteration of your ImportAirfoilData.pyAnd now I’m going to go dig around my Windows archives. Edit: I found it (attached) (1.5 MB) I had augmented that really large Selig/Lednicer database with my own low Reynolds Numbers wing sections a few years ago. Need to check to see if it is outdated though.
This includes a selection of high-lift sections as well as some very high-speed laminar sections for other uses. They played very well with Rhino 4 for Windows and that old script; primarily generated stuff for hobby drones/UAVs with open source software X-Foil and an affordable program called Profili Pro. Feels a bit like starting over but much worth the learning curve to get everything consolidated onto one operating system.Have a great day, and please let me know if I can contribute to your efforts in any manner.Carl. Helvetosaur:OK, here is a new version with some more bells and whistles.Completely new way of parsing file, hopefully robust.
Detects Selig or Lednicer formats.Command line options for scale in X, curve knot style, and add points to file or not.Lednicer upper and lower profiles joined into one polycurve.That’s great that you added joining the trailing edge curve as an option; sometimes it makes sense to do so when modeling in Rhino, so having it as an option during generation is quite nice.Thank you, Mitch,Carl. OK, I did just a quick test on a the commonly used ClarkY section though do need to run out the door. Having the curve-editing in the script fixes the leading edge interpolation problem, whereas by default it is lofted with high spots.I’ll let you know if I encounter any errors, and yes I suppose it’s superfluous to make anything with the curves because it’s easy enough to inspect them after generating the objects.So far no odd behavior, and I’m going to use the OS X alias trick that you suggested tonight.Have a great day,Carl.
Alright... Attached is an updated script.
I must say I find all the different scripting languages confusing, and Im not entierly sure what I can or cant use to make the script run on Mac. For instance... Can I use the rhinoscriptsyntax commands found here: http://developer.rhino3d.com/api/RhinoScriptSyntax/win/?? It says they're intended for Python, but they're also called 'rhinoscriptsyntax' and RhinoScript doesnt work on Mac... But is this RhinoScript, or mere functions that just happen to have a rather similar name? RhinoScript code looks very different to me after all.
Anyways, here's the code I have now which works fine on my PC for what I want to do, but it seems the 'ExplodeText' doesnt work on Mac. It returns the text one more time even though it's set to only return outlines (see script).
import rhinoscriptsyntax as rs
import scriptcontext as sc import Rhino as r
sc.doc = r.RhinoDoc.ActiveDoc
geoList = []
preText = rs.AddText(text, plane, height, font, font_style=fontStyle, justification=None)
textGeo = rs.ExplodeText(preText, True)
for i in textGeo:
geoList.append(rs.coercegeometry(i)) for i in textGeo: rs.DeleteObject(i)
if BAKE True: bakeText = rs.AddText(text, plane, height, font, font_style=0, justification=None) ![]() Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |