I am trying to use Grasshopper to solve an issue I am having with a CNC workflow. I have some parts that need holes drilled at a compound angle on a 4+1 CNC machine (5 Axis, 4 CNC Axis + 1 Mechanical Axis). In order to drill holes at a compound angle, I need a reference plane that is at the compound angle, I also find it helpful to have a tilt line that represents the centerline of the drill bit for verification.
I normally just draw this information in Rhino and send it to vectorcam where I can create the NC code for this. But now I have a job that is too difficult to fit the parts on a sheet manually, so I am using an on-line subscription service called Nest and Cut to do the nesting for me. Nest and Cut finds good solutions for my nesting, but it requires a DXF Lines and Arcs file in and it exports a DXF file. Since it is only concerned with 2D nesting, it forces everything to Z=0 and so when I get the file back, all my 3D tilt lines and lines I would use to create the reference plane are now useless as everything is at Z=0.
So I came up with a possible solution. My drilled holes are all at 10 degrees away from vertical, so in Rhino I drew the tilt line and made it go from Z=1.5" to Z=-1.5 and put points on different layers on the ends of it. I also drew reference lines for the plane and put points on that as well, also on different layers. I have all the points that at are at Z=1.5 on a layer named 1_5 and all the points that are at Z=-1.5 on a layer named -1_5. I also put points and lines to create the plane on other layers so I can make sense of it when it gets back from nesting all flat. It looks like this:
When I run Nest and Cut, it does a very good job of figuring out how to arrange parts on a sheet I get this result:
but everything is flat at Z=0
So I made a Grasshopper script that filters out all the points and moves them to the correct Z heights, and builds the plane and lines from the Z corrected points:
So my script works perfectlyā¦ but only by accidentā¦ itās dependent on the DXF file being in the correct order and itās just dumb luck that it works at all. I can prove this by deleting one point then creating a new point and putting it on the correct layerā¦ now itās out of sequence and it doesnāt work right.
So Iām wondering how I can modify my Grasshopper Script to be foolproof and work because of the way the input geometry is connected and not just because it so happened to be in the right sequence.
All the points that belong together are connected with lines, so I got all the lines in a list, and then I got all the start and end points:
But now I donāt know how to finish itā¦ I need to move the start and end points either up or down by 1.5inches, but to know which is which, what I need to do check each start and end point and see if it has a matching point in the 1_5 or -1_5 layers. If itās in the 1_5 I need to move it up by 1.5 inches. If itās on the -1_5 layer, I need to move it down by 1.5 inchesā¦ then just connect themā¦ since my lists Iām using were created by finding the start and end points of the line, the results will be correct even if the points on the 1_5 and -1_5 layers got mixed up, or if the lines ended up backwards. I just donāt know how to do the check to see if each start/end point is also in the 1_5 list or the -1.5 list
I am using Elefront to filter things and for some reason I canāt internalize data with that, so Iām including both the Rhino and Grasshopper files. My intention is that I would just do a select all on the Rhino drawing and bring everything into Grasshopper
CBC Center SHEET_001_QTY_4.3dm (2.5 MB)
Fix Tilt Lines and Planes.gh (148.4 KB)
I appreciate any help on this.
James