Extract and Extend Macro

I’m trying to make a macro to extract a single surface then extend it. It’s mostly working but I would like it to select exactly one surface then immediately run *ExtendSrf. so I can extend 3 sides. Is there some way I can do something, so I don’t have to hit enter after the extract command after exactly 1 selection is made?

I am trying:

!_ExtractSrf _Pause _Enter
_*ExtendSrf

but when I run it I get:

Command: _ExtractSrf
Select surfaces to extract ( OutputLayer=Input Copy=Yes ): _Pause
Select surfaces to extract ( OutputLayer=Input Copy=Yes )
Select surfaces to extract. Press Enter when done ( OutputLayer=Input Copy=Yes )
Extracted one surface.
Command: _Enter
Command: _*ExtendSrf

my _Enter command doesn’t come in until after I already hit enter myself. Is there some way to make it hit enter for me after the first selection so it will only select 1 surface then move down to *ExtendSrf?

Also for the *ExtendSrf command, I need to extend 3 edges of a plane, always the same procedure… extend the top 1" then extend the left 5" then extend the right 5". Is there some way I can have the macro put in the 1, 5, and 5 for me so I can just pick the edges in the correct order?

Hi James - for now use the Repeat command here rather than “*”

!_ExtractSrf _Pause _Enter _Repeat _ExtendSrf

The * character occasinally runs into problems when a plug-in must be launched to execute the command - it will work if you run ExtenSrf once first - fixed in V8, I believe.

-Pascal

Hi Pascal,

I have the same results with that. I did get a macro to work almost the way I want… Instead of using * or _Repeat, I just issue the _ExtendSrf command 3 times.
Here is what I have now:

!_ExtractSrf OutputLayer=Current _Pause _Enter
_ExtendSrf
_Pause
1
_ExtendSrf
_Pause
5
_ExtendSrf
_Pause
5
_-SelLayer
“Drill Alignment”
_CopyToClipboard

The only issue I am having is that I have to hit enter after I pick the surface. I can’t figure out how to stop _ExtractSrf without hitting enter and stopping it myself

When I run my macro, I Get the following, and then it waits for me to pick a surface
image

Now I pick a surface… and I get this:
image

now I have to hit enter to make ExtractSrf finish…
How can I make it not ask for another surface? and move on to _ExtendSrf?

Hi James - at some point I think you’ll need to move on to a python script…

@James_Richters

https://mcneel.github.io/rhino3dm/python/api/index.html
https://developer.rhino3d.com/api/RhinoScriptSyntax/
https://developer.rhino3d.com/api/RhinoCommon/html/R_Project_RhinoCommon.htm

-Pascal

I’ll look into that. I’ve done a little with Python so maybe I can figure it out.

@pascal

Thank you for the guides. A lot of new things to learn, but it looks like I could make scripts to do exactly what I need.

EditPythonScript
Wow that was much more than I was expecting!! not only a way to edit and test scripts right in Rhino, but the entire command reference is right in there. I am impressed!

Thanks for the suggestion. I think I can probably make one big script to do my entire export process. A bit of a learning curve but it will pay off once I get it figured out.

check out the wip

with a bit of cut and paste style programming, I was able to get this working with a Python script.

import rhinoscriptsyntax as rs

def ExtractAndExtend():
    obj_ref = rs.GetObject("Surface to extract", 8, True, False, None, True)
    if obj_ref:
        parent_id = obj_ref.Object().Id
        surface_index = obj_ref.GeometryComponentIndex.Index
        if surface_index >= 0:
            rs.ExtractSurface(parent_id, surface_index,True)
    rs.Command("_-ExtendSrf Pause 1")
    rs.Command("_-ExtendSrf Pause 5")
    rs.Command("_-ExtendSrf Pause 5")

ExtractAndExtend();

It works great, and doesn’t wait for me to hit enter after extracting the surface.

@pascal Thanks for the suggestion to learn Python scripting for Rhino. While I still have a bit of a learning curve ahead of me, I can see how it is much more powerful.