One extrude command for extruding curves and surfaces

Hello there !

I would like to ask if is possible to make script, that will decide what command will be used if is selected curve or surface. Simply merge the 2 existing commands: ExtrudeCrv and ExtrudeSrf to one, based on selection. I have done something, but it not working as I expected, I´m totally newbie in scripting.

Dim strObject

strObject = Rhino.GetObject(“Select a curve”)

If Rhino.IsCurve(strObject)Then

Rhino.Command "_SelPrev"
Rhino.Command "_ExtrudeCrv"

Else

Rhino.Command "_SelPrev"
Rhino.Command "_ExtrudeSrf"

End If

It will be very helpfull instead of using 2 commands, it will make Rhino more user friendly :slight_smile:

Thank for help
Tom

i always wished some of the commands were like this.

Some are… In V3, they started to combine commands. I believe the popular term adopted by the users was “uberize”…

There was a ton of discussion on the old newsgroup, a lot of uproar, and the process was finally abandoned. However, a few combined commands survived - notably Split, which in V2 and earlier was SplitCrv and SplitSrf…

that makes no sense? what was the reasoning for abandoning? rewriting commands for scripting issues?

Well, as I said, there was an enormous amount of discussion in the newsgroup, IIRC a lot of it critical/complaining (maybe someone who was around at the time has better memories). Enough so that the process was given up - some combined commands that had already been done remained but nothing further was done.

Again IIRC, Extrude had indeed been made into a combined surface/curve command at one point in there and that one got backed out into ExtrudeCrv and ExtrudeSrf - maybe I’m wrong about this, but that is my recollection.

As to the reasons - mainly as Pascal has been mentioned, Rhino commands have a plethora of command line options and they can be different for each type of object, so managing them all in one combined command can get difficult/confusing. As Rhino accepts preselection on many commands, it might also end up making it difficult to create reliable macros.

Another reason is that curve-based commands can generally pick both curves and surface edges - in a combined curve/surface command, when you pick a surface somewhere near an edge, Rhino wouldn’t know if it’s the surface itself you want or the edge curve - so you would get a multi-selection box.

Anyway, that’s about all I remember from those old days.

thanks mitch, now i totally understand and agree.

Hello,

Thank You for your time and your reply.

Maybe I didn´t get it, but when I have selected some object in scene, rhino knows what type of object I have selected right ? If I have selected curve, edge, face, etc…and then rhino can be able decide what type of extrude command will use. Why user have to remember hundreds of commands for such easy extrude function ?

It could be done via rhinoscript or python isn´t it, with command like IsCurve, IsSurface, IsEdge can rhino detect what type of object I have selected, and then will use the right extrude command.

I´ve done some really “stupid” code here, and it partially works as I expected, but I don´t know how to store the selected object. When I run this script, I select the curve or surface, it detects what it is, but then rhino ask me again for pick the object, and I have to select it again. I don´t know how to store the selected object for another operation. And also it not working when some edge is selected.

Dim strObject

strObject = Rhino.GetObject(“Select a curve”)

If Rhino.IsCurve(strObject)Then

Rhino.Command "_ExtrudeCrv"

Else

Rhino.Command "_ExtrudeSrf"

End If

I will be really glad if someone could help me with this

Thanks Tom

What happens if you select both a surface and a curve?

You don’t actually need to, the GetObject() method allows you to add optional arguments to both allow the preselection of an object as well as leave the object selected once you pick it.

image

Yes, GetObject in Rhinoscript does not allow for subobject selection like surface edges. You would need to use Python for this. You would then need to get the underlying curves from the surface edges in order to extrude them, so some RhinoCommon.

When You have enabled Gumball and select whatever you want, edge, curve, surface… hold Ctrl and move, it actually extrude objects independently what type of object it is, so it has to know what type of object it is. I use a lot this function, but I miss the option of direction, lenght… same as for ordinary extrude command. Is there any way to use some script like gumball works with Ctrl, but with options like direction, lenght, both-side…etc ?

Thank a lot
Tom

Yes, there is. The basics are relatively easy to script. The more difficult part is doing it so it has a dynamic preview like the Extrude commands have. That requires a fair amount of code and knowledge of scripting/programming.

If you don’t want a dynamic preview but just want to set some options like direction or both sides, then type an extrusion distance at the keyboard and enter, this can be done relatively easily.

Hi @tomodelar, it is partially there when dragging the gumball direction arrows, try this:

  • Select surfaces and curves
  • start to drag on one of the x,y,z direction arrows
  • type the distance (length) into the commandline, don’t press Enter
  • the direction and distance is constrained
  • hold down CTRL if you like a single sided extrusion
  • additionally hold down SHIFT to make the extrusion bothsides

_
c.