Selname-Selgroup-etc- for input inside commands?

Is there a way to use selname, selgroup, sellast as input in a command? I cannot get them to do anything except select them.

Is there a way to use them as the input points inside your commands?

Example. I make a 2 pts.
1 point at w0,1,0 Then I name it pt1
1 point at w0,4,0 Then I name it pt 2

My goal is to make a line. Luckily, there is a command, Linethroughpt. So if I select them first, I can use the command and make a line from them.

But, onto different commands.

srfpt, which makes a surface through points. Now, I would like to be able make a square surface from the 4 points.

Without clicking on them in order.

Even without a macro, in a command.

So I have 4 points names pt1, pt2, pt3, pt4 and I want to make a surface from them from selname-pt1 to selname pt-2, then from selname-pt2 to selname pt3 and so on until its done.

Even using selname interactively just using a command, is this possible? By choosing from the dropdown selname box, the starting point, then choosing from dropdown selname box pt 2 for the second point and so on…

Is there anyway to do this interactively, or in a macro. Use named objects or groups for reference points and starting points etc…?

Thank you very much.

_SrfPt doesn’t allow preselection of points in this case… (perhaps it should)

A macro is possible, but it’s a bit complicated:

! -_Selname pt1 -_Selname pt2 -_Selname pt3 -_Selname pt4 _CurveThroughPt _Degree=1 _Closed=_Yes _Enter _SelNone _SelLast _Explode _EdgeSrf _Delete

A script would be shorter with rs.AddSrfPt()

import rhinoscriptsyntax as rs
def SurfaceFromCornerPoints():
    msg="Select 3 or 4 corner points"
    pts=rs.GetObjects(msg,preselect=True,select=True,minimum_count=3,maximum_count=4)
    if not pts: return
    rs.AddSrfPt(pts)
SurfaceFromCornerPoints()

–Mitch

1 Like

O sweet! You updated it with a script! ANywho, I didn’t thank you yet Mitch, but that was because I was gonna put the resulting macro from your tips on here when I did, and thank you for helping me complete my mission. But there’s some troubleshooting. I haven’t played with your script yet, but basically my macro:

  1. would run area centroid.
  2. Switch to top view
  3. Somehow contrict the 4 surface corner points to the z level that the area centroid produced.
  4. Then just pick 4 points around the object
  5. Have a nice cutting in half plane, useful for flowing objects/orienting/ rolling and unrolling/etc…

But even better would be a bounding box bottom face wireframe turned into a surface, that is risen to the z level that the area centroid command produced. This would be useful for the unrolling and rolling back up, flowing objects etc…

You could make the macro etc… to make the surface from the bounding box, command move, move from midpoint, and be able to move the cutting plane to either the area centroid point or a little less than half, etc…making it easy to make it exactly half or adjust according to the shapes and how they extruded/ or actuall extrusion distance you want.

Of course deleting the rest of the wireframe, the points or lines used in making or cutting surface,etc…

So, it would be a 2d x/y axis bounding box- cutting plane macro/script

Basically it sounds like you want a world Z parallel cutting plane through the object volume centroid - did I get that right? --Mitch

yep, or just almost there. By making it switch to a side view, with a move from and osnap mid on. In the middle of the move command, with only the move end point left.

Which would allow to rise the surface frm bottom of bounding box to the areacentroid point, or little over a little under depending on the design. Of course if you did the script, one could just move it manually themselves, or have a little macro to move it from its position.

I think it could be kinda handy.

ALso handy for extrusions, that you later decide to mirror a portion of. So in aid of creating extrusions that are double sided. Which would kinda be like extrude both sides, except coming from closed curve, and tapering or whatever both ways. So it would make some cool custom extrusions a little easier. Which would be castable as solids, or 3d printable, but not really feasible machined.

I’m getting this when script is ran. Did I enter the script wrong?

Here’s what I got in my button:

! -_RunPythonScript
import rhinoscriptsyntax as rs
def SurfaceFromCornerPoints():
msg=“Select 3 or 4 corner points”
pts=rs.GetObjects(msg,preselect=True,select=True,minimum_count=3,maximum_count=4)
if not pts: return
rs.AddSrfPt(pts)
SurfaceFromCornerPoints()

You need an open parentheses after RunPythonScript (

And a close parentheses after the whole thing
)

dur, that’s what it was. I think I tried it with " " Thank you

Perhaps something like this…

CentroidCutPlaneXY.py (1.2 KB)

I’m getting errors in 2 or 3 strings no matter what I do. It is giving me the bottom of the bounding box though. Which by the way would be fine with me. Altough naming, and moving the item afterwards in a macro may have some problems with the errors, What was to happen after the bottom of bounding box is isolated?

Once again, thank you. I don’t know long I’d be sifting though things, or not knowing important things without ya.

Sorry, changed something and forgot a pair of brackets. Please discard the original and re-download the script from the original link. --Mitch