@jmoo wrote:
How can I make a mesh join another mesh if its touching a certain color?
basic principle: If black mesh is touching red mesh, join.
Posts: 4
Participants: 3
@jmoo wrote:
How can I make a mesh join another mesh if its touching a certain color?
basic principle: If black mesh is touching red mesh, join.
Posts: 4
Participants: 3
@markgtaber wrote:
I'm trying to write a batch open and save script in Python to run on a Mac. I'd like it to open and saveas (or export) files automatically without input from the user. The best I can get it to do is bring up the open file dialog box. At that point the user has to select a file to open and hit enter. The Command() function is supposed to be able to take an argument specifying the file path but this doesn't seem to work on a Mac. Does anybody have any ideas?
`import rhinoscriptsyntax as rs
import osdef BatchSaveAs():
#Get folders
folder = rs.BrowseForFolder(message = "Select folder to process")
if not folder: returnsaveFolder=rs.BrowseForFolder(message = "Select folder to save files") if not saveFolder: return found = False ; counter = 0 ; for filename in os.listdir(folder): if filename.endswith(".STEP"): found = True ; counter += 1 fullpath = os.path.join(folder,filename).lower() rs.EnableRedraw(False) #Close the current file rs.DocumentModified(False) rs.Command("_-New _None",False) #Open file to convert rs.Command ("_-Open " + folder + "_Enter") comm="_-SaveAs" rs.Command(comm + chr(34) + saveFolder + chr(34) + ".3dm" + "_Enter") if not found: print "No .STEP files found in selected folder!" else: print "{} files converted to 3dm format".format(counter) #open a blank document to finish rs.DocumentModified(False) rs.Command("_-New _None",False) rs.EnableRedraw(True)
BatchSaveAs()`
Posts: 1
Participants: 1
@nickp1 wrote:
I created a plugin from a debugged and working Python script. Initially the plugin did not execute as the original script and terminated before running to completion. The original script opened an output file and wrote text to the file and it seems that this was the problem. After the file open, write and close statements were commented out the plugin ran to completion and produced the correct drawing in Rhino. Is there a problem with file I/O when compiling Python and creating a plugin?
Posts: 1
Participants: 1
@Willem wrote:
Hi
As per request in another topic I translated 2 scripts from VB to Python to work on Both Windows and Mac:
PullGripsToCurve.py (741 Bytes)
PullGripsToSurface.py (727 Bytes)
The script pulls controlpoints (aka grips) to the selected curve or surface.
If you run the script once via the scripteditor, it wil register an alias with the filename minus the extension. So command aliases will be PullGripsToCurve and PullGripsToSurface.
( I don't know if this works on the mac side as well; please let me know)Change the filename before running and that alias will be registered
Keep in mind that the scriptfile should remain at the locate from where you ran it. so choose it wisely or just rerun it after moving.Enjoy!
-Willem
Posts: 1
Participants: 1
@JKayten wrote:
I've mentioned this before. There's another user that also spoke of a feature that would be very useful when dealing with fine detail; that is the ability to turn out of an ortho view of some closeup detail of a model into an orbiting mode. For instance I'd like to make control point adjustments on compound surface curvature from an ortho position first and then slightly turn that area of concentration to see the effect in a perspective view without having to change views and zoom back into the area in question. Perhaps a keystroke while holding the right click could toggle the navigation from the panning in ortho to orbiting?
Update - Oh shoot! I just found it - shift+command (in mac) and I'm on my way.
Never mind -
Posts: 1
Participants: 1
@jeffoulet wrote:
Hi all,
I'm really new to Python/Rhinocommon and I'm trying to get the index of a BREP vertex by picking it. I've already this code, but it only returns the index of the edge where the point is picked.import rhinoscriptsyntax as rs import Rhino import scriptcontext as sc def GetBrepVertexIndex(): gp = Rhino.Input.Custom.GetPoint() gp.SetCommandPrompt("Pick point") gp.Get() if gp.CommandResult() <> Rhino.Commands.Result.Success: return gp.CommandResult() brep = gp.PointOnObject() print brep.ObjectId print brep.GeometryComponentIndex.ComponentIndexType print brep.GeometryComponentIndex.Index GetBrepVertexIndex()
Is there any way to get this information?
Many thanks in advance?
Posts: 1
Participants: 1
@Sachin_Saxena1 wrote:
Can anyone please help me out with the mirror transformation in Rhino python ?
As of now I have come across a command Rhino.Geometry.Transform.Mirror(point, normal) ,but I am clueless as to how I can actually use it in my code to mirror a curve.
Posts: 17
Participants: 5
@djnelson75 wrote:
import rhinoscriptsyntax as rs LineList = x PtList = y result=[] count = 0 for a in LineList: for b in PtList: test = rs.IsPointOnCurve(a,b) result[count].append(test) count += 1 a = result
Can anyone tell me why this doesn't work.
Posts: 4
Participants: 2
@cbass wrote:
Hi everyone,
I need to streamline my process. I’m starting with text dots. I need to convert them to a specific font for CNC engraving (the font can only be comprised of closed curves, which are necessary for the nesting software I use)…
I can manually generate the font using Rhino\s TextObject dialog (selecting “curves” as output). It works fine, except I have hundreds of text dots. I need to automate this.
The attached image shows what seems like a solution, except that the result isn't quite right. The “e” characters are funky looking and some areas converge to a point. Apparently, the curves derived from exploded text are not the same as the curve output from the TextObject command. Am I overlooking something? Not all fonts create this problem, but I’d like to continue using the font in the example (Existence Stencil Light).
I’m not bound to this workflow either (grasshopper and/or scripts are welcome), so if you know another way to go from textdots to well behaved curves (as created with the TextObject command) please point me in the right direction. Many thanks!
cbass
Posts: 6
Participants: 3
@AndersDeleuran wrote:
Hi All,
I'm trying to wrap my head around how the Rhino.Geometry.Intersect.Intersection.CurveSelf class deals with Polyline Curves. See images below and attached files for case reference.
As far as I can tell it works as expected when the intersection event type is a point (see Case C). However it seems to miss cases where the intersection event type is an overlap (see Case D and E). This might just be me misunderstanding how the class is supposed to work. However, I've made two additional observations that makes me think that this might not be the case:
1) Performing Curve-Curve intersections on two polylines returns the results I would have expected. That is, a single point-point intersection returns one event and the event.IsOverlap property is False (see Case A), and, a single overlap intersection returns one event and the event.IsOverlap property is True (see Case B).
2) When performing Curve-Self intersection on a polyline where overlapping edges/vertices lie on a line, only the first and last vertices are considered intersections (see Case D). When the edges/vertices are NOT on a line, all the vertices are considered intersections.
In the attached Grasshopper file I'm calling the intersection functions using GHPython to get the IsOverlap property, but I have also verified this behaviour using the respective GH components.
Any ideas?
Best,
Anders
Ps. Cross-post on the Grasshopper forum. Apologies, but I figured that you McNeel devs might not see this over there.
160122_PolylineCurve_CurveSelfIntersectionOverlaps_01.gh (90.0 KB)
Posts: 1
Participants: 1
@SmallChief wrote:
Hi,
I am trying to do a simple visibility check in Python with the following code:import Rhino
import rhinoscriptsyntax as rsa = rs.GetObject()
print Rhino.Display.DisplayPipeline.IsVisible(a)The result is following error message:
Message: IsVisible() takes exactly 2 arguments (1 given)As I understand it the method takes the arguments self, object.
Do I need to point the method to the right pipeline?
How would that be done?Thanks!
Henning
Posts: 4
Participants: 2
@maxz wrote:
Hi,
I am trying to project a random selection of objects onto a surface, using the PullCurve function. Since projection is only possible for curves, and will generate an error message when a non-curve object is selected, I am filtering out the curves with IsCurve. Here is the code part:
pulllist= rs.SelectedObjects()
rs.UnselectAllObjects() for pully in pulllist: if rs.IsCurve(pully): resultcurve=rs.PullCurve(cookiesurface,pully) if resultcurve: rs.SelectObject(resultcurve[0]) rs.ShowObject(cookiecurve) rs.SelectObject(cookiecurve)
Trying it, it was a hit-and-miss. Sometimes it worked, sometimes it came up with a message regarding the SelectObject function: "argument requires a guid or a string representing a guid"
I found out that this happened when the selection included a Text Block, and after more research that a Text Block is actually a tuple of two guides. Changing the argument toresultcurve[0]
solved the problem, although there is no visible evidence of the projected Text Block (which is fine).
What puzzles me is how the Text Block got past the IsCurve filter. Anybody an explanation?Max.
Edit: I reversed the change in the script, and it still works without error messages, go figure!
Posts: 2
Participants: 2
@benjamin wrote:
Hi,
Just exploring if panning is scriptable in Rhino 5.0, as there are no commands for precise panning. It would be very useful for arranging drawings in detail views for layout.
For example I would like to pan within a detail view 400 units in the x direction.
Any ideas how this would be possible?
Posts: 4
Participants: 2
@djordje wrote:
Hello,
I am currently struggling to call a method from loaded .dll assembly. Assembly is a part of WinMapGIS and Map Window open source projects for manipulation of GIS data.
The issues is that, I can call any property or method which does not take any arguments.
But once a method requires at least one argument, an error message appears:Could not convert argument 0 for call to Open.
I am basically trying to replicate the C# code which opens a .shp file:
using MapWinGIS; string shpfilename = "C:/example.shp"; Shapefile sf = new Shapefile(); sf.Open(shpfilename, null)
Here is the ironpython replication:
import clr clr.AddReferenceToFileAndPath("C:/mapwindow_dlls/Interop.MapWinGIS.dll") import MapWinGIS sf = MapWinGIS.ShapefileClass() shpfilename = "C:/example.shp" sf.Open(shpfilename, None) # raises the error message
On the last line, an upper error message appears (Could not convert argument 0 for call to Open).
Here is the signature of the "Open" method:
Open(self: ShapefileClass, ShapefileName: str, cBack: Callback) -> bool // MapWinGIS.ShapefileClass [DispId(11)] [MethodImpl(MethodImplOptions.InternalCall)] public virtual extern bool Open([MarshalAs(UnmanagedType.BStr)] [In] string ShapefileName, [MarshalAs(UnmanagedType.Interface)] [In] ICallback cBack = null);
Just to make it clear: In upper C# example the
Shapefile
class is used, while I usedShapefileClass
class. The reason is that,Shapefile
class does not containOpen
method. When I even try to instantiate it:
sf = MapWinGIS.Shapefile() # raises an error
It raises an error:
Cannot create instances of Shapefile because it is abstract
Looks like
ShapefileClass
is an implementing class.I did a little bit of search and the same thing happens at ironruby.
Author of this question states that the issue might be with the type of argument, supplied to the "Open" method (
shpfilename
in this case).I tried seeking for help on both ironpython mailing list, stackoverflow, and by contacting the developer of the MapWinGIS / Map Window projects. But without success.
Here are all the necessary .dll files (the upper
mapwindow_dlls
folder) along withexample.shp
file (.zip file is 27MB in size).I would be very grateful for any kind of help.
Posts: 1
Participants: 1
@detlef_mueller wrote:
Hi,
I tried to achieve something like this by python. I have a number of curves(1) which are ending on another curve(2) and want to get the curves(1) connected by an arc which should be tangent to curve(2). Since there is nothing like circle TTT in Python, I have no idea how to solve that. Can someone help me out with this?
See also screenshot of before and after.
Thanks,Detlef
Posts: 4
Participants: 2
@oliver55000 wrote:
I'm relatively new to python, and have started learning for the above reason.
I want to be able to model guitar necks (and then cut on a CNC router) relatively quickly, but most of all accurately (which is where the scripting comes in)
The fret slot distances use a constant (17.81...) divided by the string length which is repeated 22+ times with an ever shortening string length. Online I have found a python version of a trusted calculator and was wondering if anyone had tips/ideas on connecting the mathematics in said calculator to something like rs.addpoint (or addline) to create an array of points/lines in the correct spacing.
Below is the fret calculator script.
# From Stewmac # To calculate the scale length for stringed instruments # Notes on fret layout # The most accurate way to lay out your scale is making all measurements # from the nut (using the "fret to fret" distance only to confirm your layout). # Laying out frets only by measuring fret to fret will compound error. # For example, if you're laying out frets by marking with a scribe and your # accuracy is plus or minus 2 millimeters, you could be off by as much as # 24 millimeters at the 12th fret. # Measurements are given from the end of the fingerboard (face of the nut) # to the center of a fret slot. # WRITTEN FOR PYTHON 3.3.2 #-------------------------------------------------------------------- Im = '' const = 17.817 # Do not change this def fretCal(ScaleLength, nofret): '''(number, number)-> float Calculates the fret positions for any stringed instrument Given 'Scale length', 'number of frets' in inches or mm >>> fretCal(19, 18) Fret 1 from nut 1.066 inches Fret 2 from nut 2.073 inches ............................ >>> fretCal(635, 22) Fret 1 from nut 35.64 mm Fret 2 from nut 69.28 mm ''' if ScaleLength < 99: scale = ScaleLength Im = 'inches' if ScaleLength > 100: scale = ScaleLength Im = 'mm' for i in range(1, nofret +1): ScaleLength = ScaleLength - (ScaleLength / const) print('Fret', i, 'from nut',round(scale - ScaleLength, 3),Im) #--------------------------------------------------------------------
Hope someone can help!
Oliver
Posts: 2
Participants: 2
@egradman wrote:
Using Rhino.Common, I can prompt the user to select a sub-surface of a polysurface (which I'm adding to the document for further manipulation). How can I obtain a reference to the polysurface that contains this subsurface?
Here's my code for sub-surface selection.
import Rhino import System.Guid import scriptcontext import rhinoscriptsyntax as rs def GetSubSurface(prompt="select subsurface"): # get a surface of an object go=Rhino.Input.Custom.GetObject() go.GeometryFilter=Rhino.DocObjects.ObjectType.Surface go.SetCommandPrompt(prompt) go.Get() print go objref = go.Object(0) go.Dispose() brep = objref.Face().DuplicateFace(True) guid = scriptcontext.doc.Objects.AddBrep(brep) if (guid != System.Guid.Empty): rc = Rhino.Commands.Result.Success scriptcontext.doc.Views.Redraw() return guid
Posts: 3
Participants: 2
@krsnadas wrote:
I read somewhere that WScript methods
GetScriptName
andGetScriptFullName
don't work for Rhinoscript. I want to confirm if this is true and if there is some other way to get the path of the script file that I loaded using_LoadScript
?
Posts: 3
Participants: 2
@Telfer_Scott wrote:
I'm having some trouble getting this python script to work. In brief, in want to be able to select a subset of grip points from a mesh object, and move them all so their z coordinate = 0 (either manually or automatically). I've tried a number of variations but can't seem to get the right way to give the selected grips to the _SetPt command. Any ideas? Thanks in advance.
import rhinoscriptsyntax as rs # Select grips grips = rs.GetObjects("Choose points to move", filter=16384) # Edit selected points setpts = ("-_SetPt " + "selid " + str(grips) + "_Enter " + " _XSet=_No _Enter " + " YSet=_No _Enter " + " ZSet=_Yes _Enter" + " Alignment=_World _ Enter ") rs.Command(setpts)
Posts: 3
Participants: 2
@Jarek wrote:
I have noticed that the EnableRedraw method will not only redraw the vieports but also seems to be affecting the layers panel. I can see that the selected layer is 'flickering' on each redraw. This is distracting and seems to be slowing down the script. I am in a loop with frequent redraw on/off. Would there be any way around this? Is it necessary for redraw to refresh layers panel as well ?
thanks,
--jarek
Posts: 2
Participants: 2