How to exclude press the "Enter" button using the macro?

Hi

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?

Thanks

Hi

Instead of Enter Try using Pause - it works like Enter but lets you continue execute the command further. At the end use Enter.

Regards :slight_smile:

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()

c.

Thanks so much Clement!
Your script works perfect :yum:
What should I write in the your script to pull curve and on one component of the polysurface?

So is it not possible with a macros?
Just for interest)

@leex,

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. :wink:

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…

c.

Preselect works only for the curve.
But when I choose the surface that is going to ask for confirmation.

I have just noticed that your script when I select polysurface a curve is projected on the back side of polysurface :confused:

No, i´ve meant using the regular _Pull command in Rhino. This works for me using a curve above a surface or a polysurface box:

  • Preselect curve and surface
  • Run _Pull

or

  • Preselect curve and polysurface
  • Run _Pull

or

  • Preselect curve and subselect one or more polysurface faces
  • Run _Pull

do you see something different ?

c.

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.

-Pascal

Oh yeah. It worked for me.
I never have done this way.
Now I know ) THX

@pascal,

this seems to work too, for one surface or a brepface:

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()

but using _Pull with preselection seems to be much easier i guess :wink:

c.

The result was a great script.
Just right.

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

Once again, thank you very much :muscle: :yum:

1 Like

Nice- as always- very concise.

thanks,

-Pascal

1 Like