FilletSrf in PythonScript

Hi all,

I just tried to fillet 2 surfaces with pyhton.
Unfortunatelly it does not have the “extend” option, so that it would extend the fillet if the surfaces are not homogenious at their intersection.

So I tried to solve it via the commandline.

rs.Command("-FilletSrf ")
rs.SelectObject(first_flap)
rs.SelectObject(second_flap)

But Rhino still is asking me to chose the first surface.
Where is my mistake?

Thanks a lot!

Tobi

Hi Tobias - something like this:

rs.Command ("FilletSrf SelId " + str(first_Flap) + " SelId " + str(second_Flap) )

Assuming the flaps are actually GUIDs as far as rhinoscriptsyntax is concerned.

-Pascal

Hi Pascal.

Yes they are GUIDs. And it works out perfectly.
Last question concerning that would be:
How can I get the ID of the element that operation creates?

So far! Thanks a lot (honestly).

Tobi

Hi Tobi - this should work -

If rs.LastCommandResult() == 0:
    ids = [id for id in rs.LastCreatedObjects()]

-Pascal

Pascal.
Yes. Again: works out perfectly.
Thanks a lot!
Tobi

Hi Pascal,

so I tried to do the next step myself.
Offsetting that surface.

rs.Command("OffsetSrf SelID " + str(panel) + " ")
But nothing happens, it again is asking which one I wanna offset.

I really seem to have trouble with that commandline-logic and -syntax.

Thanks in advance.

Tobi

Hello - you’ll need to look at the inputs required for the OffsetSrf command but it might be simpler to use

rs.OffsetSurface()

and not the Rhino command.

There is a Scriptng forum here:
https://discourse.mcneel.com/c/scripting

and good resources here:

-Pascal

Hi Pascal,

I am well aware of the offset in Phyton.
I am dealing with a brep though, that fails offsetting this way.

When I use the commandline and do it manually it’s working fine, though.
So I thought, that it might be a good idea to offset it via the commandline.

Thanks

Tobi

Hi Tobi - you can delve into RhinoCommon and offset the brep, e.g.

def OffsetBrep():
    
    id = rs.GetObject(preselect=True)
    brep= rs.coercebrep(id)
    oBreps = Rhino.Geometry.Brep.CreateOffsetBrep( brep, 2, False, True, .001)
    
    for brepList in oBreps:
        for x in brepList:
            if x.IsValid:
                sc.doc.Objects.AddBrep(x)

    rs.Redraw()

-Pascal

Pascal: Perfect. :slight_smile:
Thanks a lot for your help.

Hi Pascal.
One last question.
If I wanna get the ID of the brep that got created. How would I get that?

I just thought I might also use phytons “PointClosestObject”, but that would be a lot of iterations it you’d have let’s say 1000 breps that you’d create.

thanks
Tobi

Hi Tobi - each time you add a brep using

sc.doc.Objects.AddBrep(x)

it returns the id of the added brep, so you can sat up a list ahead of time

newBreps = []

then add to the list every time you put a brep in the document

newBreps.append( sc.doc.Objects.AddBrep(x))

-Pascal

again: perfectly working out.
Thanks!