Some commands to need a select one or more objects to execute the command.
For example, consider the command _Pull
This command use one or more curves and the one or more surfaces.
In the process of executing the command must first select the curve or curves, press enter when done. Select the surfaces and then press Enter to complete the command.
For example, I will use only one curve and only one surface.
In this case, there is no need to enter the keys
Is it possible with the help of a macro to find good way to stop the selection process without an Enter key / Right mouse button / Spacebar
Or for this purpose it is necessary to write the script?
It works only this macros:
-_Pull
_Pause
_SelSrf
_Enter
But selected all surfaces, and on all surfaces pulling curve.
Before that, I wrote this:
-_Pull
_Pause
_Select
_Pause
_Enter
To select only one desired surface.
But it does not work that to stop the selection process without an Enter key
try below. If you want to keep the curve to pull, change the option delete_input=False:
import rhinoscriptsyntax as rs
def PullCurveToSurface():
crv_id = rs.GetObject("Select curve to pull", 4, True, False)
if not crv_id: return
srf_id = rs.GetObject("Select surface that pulls", 8, False, False)
if not srf_id: return
result = rs.PullCurve(srf_id, crv_id, delete_input=True)
if result: rs.SelectObjects(result)
PullCurveToSurface()
you can add this so it allows to pick a surface or polysurface:
srf_id = rs.GetObject("Select surface that pulls", 8+16, False, False)
btw. It seems that the _Pull command in Rhino allows to post-pick (multiple) surfaces but no polysurface.
not sure, i just did not find a way. Btw. have you tried _Pull to preselect the curve and surface or polysurface ? This seems to work without script or macro and it pulls to a polysurface without asking to pick surface(s) from it…
Hi Clement - I guess using rs.GetObject with subobjects=True will help here, but it may complicate things because, if I remember right, the function then returns an ObjRef and not an Id (can’t test right now, but I’ll fuss with it in the morning). You need to get at the surface via RhinoCommon.
Thank you very much Clement and Pascal for the work it helps automate several actions.
It is for calculating the midcurve for the mathematically incorrect surface.
! _MeanCurve
_Pause
_Pause
_SelLast
_-RunPythonScript
(
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
def PullCurveToSurface():
crv_id = rs.GetObject("Select curve to pull", 4, True, False)
if not crv_id: return
ref = rs.GetObject("Select surface that pulls", 8, True, False, None, True)
if not ref: return
crv = rs.coercecurve(crv_id, True)
tolerance = scriptcontext.doc.ModelAbsoluteTolerance
curves = crv.PullToBrepFace(ref.Face(), tolerance)
if curves.Count > 0:
ids = [scriptcontext.doc.Objects.AddCurve(c) for c in curves]
rs.SelectObjects(ids)
rs.DeleteObject(crv_id)
PullCurveToSurface())
The first part of the macro, and then your script.
Preselect very good for only isolated commands