Wish: directional trimming

often do i face situations where i have to trim one side of a line entirely keeping the other. one way to partially do it is to select the trimming object and when asked to select object to trim i hit ctrl a or cmd a and voila one side however it evaluates that gets magically swept away. but thats just too coincidental and does mostly not trim the curves i want.

so now my question is there no way to select which direction it should trim? or if i have a circle and want to trim everything outside the line or even the other way around? i am talking about situation where you cant just frame all lines sticking over.

You can use a small script for trimming with closed curves…

MultiNestedBoundaryTrimCurves.py (4.1 KB)

Otherwise, one way to attack the problem is to use Split instead of Trim, then Window/Crossing/SelBrush/Lasso to select the parts to delete…

–Mitch

Hi Richard - SelBrush works inside Trim, so that might help. It does not help in the closed curve case, but that may be a bug…

-Pascal

Hi pascal,
We are in the R4Mac category so no SelBrush yet.

akash

@Helvetosaur thank you very much, as usual you throw in some neat helpers

@pascal sure… but its still fiddly as… hence wishing for something like suggested. i guess that should be possible… something like when you offset a curve where you have directional option already. now if that would be implemented into trim… uh lala i must say… or not?

@Akash well what shall i say… i left that purposely open because i know there is nothing like it wether in windows nor on mac rhino… and thanks to @dale’s obsessive urge to recategorize everything thats what happens :joy: but does not matter anyway. does not make much of a difference now :slight_smile:

@RichardZ

Below are a couple of scripts to try. The first will ask you to select a collection of curves to trim, then a trimming curve, then pick a side to trim off. The second is the same, but you do not need to select the first collection, it will consider all visible/selectable curve objects as possible candidates to trim, so all you have to do is pick the trim curve and the trim side. All trimming is projected in the active viewport CPlane normal direction, so “apparent intersections” work.

Note that it will not affect any curve that does not intersect the trim curve - i.e. it will not delete any “free” curves that do not touch the trim curve even if they are on the pick direction side - otherwise the results would be quite unpredictable.

As this relies on offsetting the original curve to determine which side to trim, and as offsetting curves can sometimes be unreliable in Rhino, it might fail with some odd curves (I’m sure it will sometimes). If I did my job correctly, you will get a polite error message, if not the script might just error out…

TrimCrvsPickDirection.py (4.0 KB)
TrimAllCrvsPickDirection.py (4.0 KB)

–Mitch

1 Like

@Helvetosaur you are a script machine, one word and you bombard one with your fresh efforts :astonished:
did my suggestion above with offset inspire you making one maybe? i must say it works very nice. thank you :slight_smile:

just a few things if i can provoke you a bit more with this. if i want to select multiple curves like here for instance the 2 orange ones below and i want to trim all between those two, could that be adapted?

something like hatch and trim if that helps, and also that the curves remain on their initial layer, when i use your py script they merge.

and something more, you write: [quote=“Helvetosaur, post:6, topic:39373”]
it will not delete any “free” curves that do not touch the trim curve even if they are on the pick direction side - otherwise the results would be quite unpredictable.
[/quote]

would it be theoretically possible to do that? and why may it be unpredictable? if that would work it could maybe be welded into a quickie trim & delete tool as i once wished.

The other script posted above does exactly that…

Yeah, I can fix that, will look at it tomorrow.

Check the image below - imagine the red parabola is the trim curve and the upper red “X” is the pick point… What should trim away? Half of the green lines, obviously, but what about the magenta parabola? The closed egg? Which “side” of the red curve are they on?

For the lower “X” as a pick point - does the blue line or circle go? The magenta egg?

The point is that the tool works with open curves and is designed to trim objects that intersect with it. In that case it can (theoretically at least) test and decide which parts of the curves to delete and which to keep. Anything that does not intersect the trim curve can lead to an ambiguous situation where you have to guess, so as I said, the results might be unpredictable. I prefer tools that give me predictable results.

–Mitch

OK, below are revised scripts - the original object attributes - layer, color, linetype, etc. are now kept in the trimmed parts. I also made a small UI improvement on the boundary trimming script, so I am also posting the new version below as well.

TrimCrvsPickDirection.py (4.1 KB)
TrimAllCrvsPickDirection.py (4.1 KB)
MultiNestedBoundaryTrimCurves.py (4.1 KB)

–Mitch

you are definitely one handy and fast santa script claus :christmas_tree:

yes it does but its unlike your other script rather “complicated” to pick curves manually, while in some cases a CTRL A/CMD A to select all would quickly do but it might occur pretty equally as often that its not possible with out fiddling around like a surgeon for cases where only inside curves or outside curves are needed.

if that could be integrated into the heavy metal rocking directional trim you delivered in which you dont have to select the trims that would be outstanding. if you exclude the selected curves and see them as a sort of a boundary where offsetting should stop, maybe then it would be possible? and if not selected just trimmed or deleted.

yes some brainstorm is sure needed to conduct such a compact tool.

maybe that could work with an option extend lines if wished and free standing objects in this matter either inclusive or/and exclusive can be deleted and if else just ignored. but that might not be used often and will make it probably quite a bit of work, so rather for cases like this shown here

where you have closed boundaries and curves standing over or surround the enclosed curves, get trimmed or deleted, at least for objects in a close relative proximity. in case of multiple enclosed curves chosen a direction both would be handy which would integrate your MultiNestedBoundaryTrimCurves into the TrimAllCrvsPickDirection py.

i mean dont feel obliged now, just because i am pushing around and sure the script will become a bit longer then, but it would remain handy to have one carefully thought over tool which can include the needs of 3 different i believe. would that be possible to compact those 2 together?

I don’t find that’s the case, you have to pick the boundary curves first, certainly, then they are locked, so you can do a ctrl/cmd+A to select all the rest - assuming you want to trim all other visible/selectable curves - otherwise, yes, you do need to pick the curves you want to trim, but that’s the goal - to allow the user to choose. I prefer this to automatic assumptions. In the case of really complex “forests” of curves, it’s good practice to separate them with the usual panoply of tools Rhino gives you - color, layer, group, etc. All those selection methods are usable inside the command.

I don’t feel obliged - therefore I’m sorry to disappoint you, but I’m not going to pursue your wish. My own personal philosophy is that combination tools often do not work as well as specifically designed ones, and to get combination commands to work in Rhino often requires making the user select different command options within the procedure which actually slows them down.

The two scripts function on different principles. The closed boundary trim tool has been specifically designed to work with multiple closed and possibly nested boundaries, where what lies inside and outside the boundaries is completely defined and thus trimming can be combined with deleting.

The pick side trim tool was more specifically designed to work with single open curves that do not form a specific region - although it also works fine with single closed curves as a “side effect”.

–Mitch

well to be honest i am disappointed that you dont want to finish it :wink: why even starting to make something convenient if you drop it right there at the merging part… where the tool can fulfill its duty to its utmost pleasure of the user :slight_smile: understanding how a tool can work is a long process i agree, but it would be almost done here…

but thanks so far you have been very helpful