I need help writing a script/tool

Looking for some help trying to write a script to make a tool buuton to do this easy one …thanks

Hi,
trying to learn python myself, but this seems like it would be better in Grasshopper.

Is the objective to have different shapes for the shank embossed areas? When you say you have a lot to do, are thy all the same or is it just to project the curves, offset surface, then boolean out the shape?

In Rhino it may be quicker, once you have the shape on the shank split, offset one side into ring said amount then just extract first surface and join indent to rest of shank. Instead of offsetting 2-sides and boolean difference. ??

Hope this helps, Randy

Hey Randy, If I offset (not solid) into ring I then have to sweep or loft the sides/join and sometimes that’s more work if things don’t loft or rail right the first time if I’m understanding your method…so I offset solid both sides to be able to do the booleon diff but I have to make a copy of the ring first as in the video so I thinking about a script to do that part something like this
(after the crv is projected)
1st. select the ‘custom’ tool now it says … select crv, select object and here is was it does… makes a copy in place of the object and hides it, splits the original with the crv and deletes the ring (split) part… offsets solid both sides the surface and deletes input!.. unhide, booleon diff offset part with ‘delete input’ option. think something like that could work looking for that ‘one’ button does all…

after all that I guess just splitting, offsetting solid, then booleon diff seems to work no necked edges!

Hi P Schmidt,
Are your curve & object / ring always the same? If they are always the same, then python is the way to go. If you would like to change curve or offset or anything, then Grasshopper might be better and I have more practise with that. You can even create the ring and change size of ring. I have a GH file to do that by US ring size.

I was working on a script to day that would copy my 1mm cz and scale by .1mm up to 3mm. So copy & hide is relatively simple

Why are you copying, then deleting the copy except for the inner crv split section and then boo leaning the original. For all that work, why not just use original?.

Once the curve is projected onto shank, just extract -copy the surface to trim. Trim with your projected curve then offset that surface to boolean with. I may have to make rhino with steps, Sounds more involved than needs to be.

cheers

Teaching my bench-working goldsmith wife Rhino, so a bit distracted. For me, once I offset the split section, I would just extract (not copy) the split section leaving an open ‘box’ and then join to original surface instead of Boolean difference.

Two ways to achieve the same thing.

Have a good one. Randy

you lost me on the extract part… trying your way I think it’s your way I get this… the original spilt srf (green) I moved out of the way for the picture normally I would just delete it… now the offset has no walls so to join them you have to rail or loft, more work… unless I missed something …for some reason the image won’t load but anyway no walls on the sides for joining the offset to the ring

Just because I was up early. there is no sweep or loft. Just join offset surface to existing shank where the split section was. I will see if I can upload a rhino that might explain.

Like most software, there are numerous ways to do things.

cheers

shank-split-test.3dm (326.0 KB)

Hi there,

Just made a script fast to copy past into a new button if you would like.

_selnone -_properties _pause _object _name ring _enter _enter
_sellast _copy w0,0,0 w0,0,0 _enter _selnone _sellast -_properties _object _name copyring _enter _enter
_selnone -_selname ring _hide 
_selnone _split -_selname copyring _enter _pause _enter -_selopenpolysrf _delete _show
_selnone -_selname copyring _offsetsrf solid=yes bothsides=yes _pause _show 
_selnone _booleandifference -_selname ring _enter -_selname copyring _enter
_selnone _selcrv _delete

for rhino 4 you need to add this at the end:

-_selname ring _invert _split -_selname ring _enter

and delete one part by hand. Result is the same

how it works. Very easy. Press the new button select the ring you want to cut press enter. Next it asks for cutting crv select the projected crv and press enter again. Picture below is my result.

cheers

Thanks,

this is Rhino script, right? Wondering about making into python. Not sure it will work on OSX version?

For windows I would probably use Grasshopper, that way I could change cutting curve on the fly.

Cool, thanks again

randy

HEY MAN THAT’S GOOD …REAL GOOD! BUT IN RHINO 4 I GET AN HOLE WITH NO WALLS? HERE’S THE SCRIPT IS SOMETHING MISSING? THANKS AGAIN I CAN’T SEEM TO LOAD ANY JPEGS i’LL TRY AND EMAIL YOU THE IMAGE IF i HAVE YOUR EMAIL

@pschmidt I’m confused slightly. I thought you found a proper solution to this in ‘wirecut’? Does wirecut not work for you in v4?
@pascal Although as I test this I may have found a bug in wirecut: I can’t get it to accept an input for cut depth point (in rhino v5). I enter a value for cut depth point, it looks like its accepting it, I left click, then command is done with no wire cut result. Maybe something wrong on my computer, will have to test on another machine later.

wire cut did not always do the job however the script for r5 works well…so far!

So the script in rhino 5 works but 4not?

just sent you an email works in 5 but not 4

Can you check this one for your Rhino 5:

    _selnone -_properties _pause _object _name ring _enter _enter
_sellast _copy w0,0,0 w0,0,0 _enter _selnone _sellast -_properties _object _name copyring _enter _enter
_selnone -_selname ring _hide 
_selnone _split -_selname copyring _enter _pause _enter -_selopenpolysrf _delete _show
_selnone -_selname copyring _offsetsrf corner=Sharp solid=yes bothsides=yes Loose=No _T 0.001 DeleteInput=Yes _pause _show 
_selnone _booleandifference -_selname ring _enter deleteinput=yes -_selname copyring _enter
_selnone _selcrv _delete

This one for your Rhino 4:

_selnone -_properties _pause _object _name ring _enter _enter
_sellast _copy w0,0,0 w0,0,0 _enter _selnone _sellast -_properties _object _name copyring _enter _enter
_selnone -_selname ring _hide 
_selnone _split -_selname copyring _enter _pause _enter -_selopenpolysrf _delete _show
_selnone -_selname copyring _offsetsrf corner=Sharp solid=yes bothsides=yes Loose=No _T 0.001 DeleteInput=Yes _pause _show 
_selnone _booleandifference -_selname ring _enter deleteinput=yes -_selname copyring _enter
_selnone _selcrv _delete
-_selname ring _invert _explode _split -_selname ring _enter

Should work. Else respond to my last mail.

no not working in 4…it’s funny as the first script works fine on my desktop rhino5 and doesn’t work on my laptop rhino5 as I hit 'undo ’ it looks like it doesn’t complete the whole script if I compare the undo’s to what the script says they don’t match…also is there a away to undo the whole operation a once instead of each step (or using to multiple undo) you don’t have to spend too much time on this it was just a ‘tool’ suggestion…but let me know … as a suggestion maybe on the last b.diff have the option to delete input in case we need to mirror the cutter to the other side of the ring?

I’ll check the ‘new’ script tonight on my laptop …
From: ritmopat@msn.com
To: discourse+39bcbd1dbcf78451fdf39165341426de@mcneel.com
Subject: RE: [McNeel Forum] new post in 'I need help writing a script/tool’
Date: Mon, 9 Dec 2013 09:20:56 -0600

no not working in 4…it’s funny as the first script works fine on my desktop rhino5 and doesn’t work on my laptop rhino5 as I hit 'undo ’ it looks like it doesn’t complete the whole script if I compare the undo’s to what the script says they don’t match…also is there a away to undo the whole operation a once instead of each step (or using to multiple undo) you don’t have to spend too much time on this it was just a ‘tool’ suggestion…but let me know … as a suggestion maybe on the last b.diff have the option to delete input in case we need to mirror the cutter to the other side of the ring?

its probably a setting difference. If you change a settings Rhino remembers the ones last time used. So you maybe used a command here on your laptop and changed something that isn’t changed on your pc. And thats why its not working. Or we both changed the same thing as you did on your pc.

Do go back at once its easiest too use runscript on a button. Example code for a button:

!-_runscript (
Option Explicit

Sub makeahole
  
Rhino.command("_selnone -_properties _pause _object _name ring _enter _enter")
Rhino.command("_sellast _copy w0,0,0 w0,0,0 _enter _selnone _sellast -_properties _object _name copyring _enter _enter")
Rhino.command("_selnone -_selname ring _hide ")
Rhino.command("_selnone _split -_selname copyring _enter _pause _enter -_selopenpolysrf _delete _show")
Rhino.command("_selnone -_selname copyring _offsetsrf corner=Sharp solid=yes bothsides=yes Loose=No _T 0.001 DeleteInput=Yes _pause _show")
Rhino.command("_selnone _booleandifference -_selname ring _enter deleteinput=yes -_selname copyring _enter")
Rhino.command("_selnone _selcrv _delete")

end sub
	
makeahole
)

after using it you can just undo all at once
for the boolean difference with deleteinput just make a right button command and say deleteinput=no