Hi - I know this subject has received some attention over the years, but I'm completely stuck trying to find the original cut length of a body. The oriented box method is good, but doesn't work for this situation.
The models we produce are typically aluminium extrusions - cut with a multi-axis saw, then machined with holes/notches/cutouts. We need to calculate the original cut length of the extrusion, but typically, one of the machining operations will have removed the geometry that an Oriented Range Box would find.
This is a simple example of the edge-length I need to find. Does anyone have a method for creating a "shrinkwrap" oriented box? Six planes would be sufficient to make the calculation - but orienting the planes is the challenge.
The part file is attached (2023 format).
There's something I don't get. In order to create the model you've shown , you already need the original length, so why the necessity of calculating it?
@pcrawley,
I'm also confused with the request. Even if the sample is made using different methods from how real parts are made, and the real parts do not contain the original extrude length, wouldn't you save material by using the minimum range box length? I was able to reproduce the same solid by extruding to range box size and split/extrude cutting using the planes set up to create the final cut size.
I did however think this would be fun to work on, so I wrote something to give the result you wanted. I initially tried to adjust the range box indiscriminately, but with the approach I used, it was growing this sample in two directions instead of one. I modified it to only adjust the range box in the longest direction, which will reliably work in all cases except those where the extruded length is less than or equal to one of the profile dimensions. Without sufficient information about real use case parts to restrict the rule in a more logical manner [like using the profile sketch plane to pick the direction for adjustment], the attached ilogic rule is the best I could do. [I left my initial approach in as a separate, unused sub routine]
Let me know if you have any questions.
I realized I was only accounting for points in the normal direction of the plane. I added code to extend to points in the opposite direction of normal.
Reach out to these guys: https://draftaid.io/
I know that their software can detect the original cut length and dimension it in drawings via intersection points.
Thank you all - and sorry, I was trying to keep the post short without all the "why" filler. It was more important than I thought!
We receive many 3rd party cad files where the solid bodies are not oriented to the origin planes. The machines we use for cutting these parts do multi-axis sawing, milling and drilling. To orient the part on machine we find the face that minimizes the number of positional changes needed to finish all the machining. The saw (it's a disk saw if that helps) needs that point in space (shown on my model) as the start of the calculation for the two angles needed for the cut. The range box doesn't find the point in question - it only finds the outer boundary of the body using a box, but the point in question lies beyond that boundary.
I know we can find the point manually (as I did with the planes to show the problem) and we can show it in a drawing, but I need to find it programmatically because we're cutting hundreds of every week and the current process is manual (= painful!).
I think I need to go away and redefine the question as it just got a whole lot more complicated in my head as I wrote this. 😂
@abdullah_elq - Thank you. I hadn't seen that software - it looks very clever and I may sign up for the demo.
@J-Camper - Thank you also - I'm going to try your example in a minute
@davescholtes - Thanks for pointing out the lack of information in the question.
Additionally, you can have a look at this rule. (I'm not sure if this is what you are looking for but you can try.) When you run the rule it will show you the "Minimum rangebox in any orientation" And give you the dimensions.
Sub Main()
Dim margin1 = 1 ' cm
Dim margin2 = 1 ' cm
Dim margin3 = 1 ' cm
' Get the current Part document.
Dim partDoc As PartDocument = ThisDoc.Document
' Get the TransientBRep and TransientGeometry objects.
Dim transBRep As TransientBRep = ThisApplication.TransientBRep
Dim transGeom As TransientGeometry = ThisApplication.TransientGeometry
' Combine all bodies in Part into a single transient Surface Body.
Dim combinedBodies As SurfaceBody = Nothing
For Each surfBody As SurfaceBody In partDoc.ComponentDefinition.SurfaceBodies
If combinedBodies Is Nothing Then
combinedBodies = transBRep.Copy(surfBody)
Else
transBRep.DoBoolean(combinedBodies, surfBody, BooleanTypeEnum.kBooleanTypeUnion)
End If
Next
' Get the oriented mininum range box of all bodies in Part.
' NOTE: "OrientedMinimumRangeBox" was added in Inventor 2020.3/2021.
Dim minBox As OrientedBox = combinedBodies.OrientedMinimumRangeBox
' Create starting box with dimensions of oriented rangebox.
Dim startBox As Box = transGeom.CreateBox()
Dim boxMaxPoint As Point = transGeom.CreatePoint(
minBox.DirectionOne.Length + margin1,
minBox.DirectionTwo.Length + margin2,
minBox.DirectionThree.Length + margin3)
startBox.Extend(boxMaxPoint)
Dim boxMinPoint As Point = transGeom.CreatePoint(-margin1, -margin2, -margin3)
startBox.Extend(boxMinPoint)
' Create surface body for the range box.
Dim minBoxSurface As SurfaceBody = ThisApplication.TransientBRep.CreateSolidBlock(startBox)
' Create transformation matrix to move box to correct location/orientation.
Dim transMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix
transMatrix.SetCoordinateSystem(
minBox.CornerPoint,
minBox.DirectionOne.AsUnitVector.AsVector,
minBox.DirectionTwo.AsUnitVector.AsVector,
minBox.DirectionThree.AsUnitVector.AsVector)
' Transform range box surface body to the correct location/orientation.
ThisApplication.TransientBRep.Transform(minBoxSurface, transMatrix)
Dim cGraphics As ClientGraphics = CreateBox(partDoc, minBoxSurface)
ShowMinRangeDimensions(partDoc, minBox)
cGraphics.Delete()
End Sub
Private Sub ShowMinRangeDimensions(partDoc As PartDocument, minBox As OrientedBox)
' Get length of each side of mininum range box.
Dim dir1 As Double = minBox.DirectionOne.Length
Dim dir2 As Double = minBox.DirectionTwo.Length
Dim dir3 As Double = minBox.DirectionThree.Length
' Convert lengths to document's length units.
Dim uom As UnitsOfMeasure = partDoc.UnitsOfMeasure
dir1 = uom.ConvertUnits(dir1, UnitsTypeEnum.kDatabaseLengthUnits, uom.LengthUnits)
dir2 = uom.ConvertUnits(dir2, UnitsTypeEnum.kDatabaseLengthUnits, uom.LengthUnits)
dir3 = uom.ConvertUnits(dir3, UnitsTypeEnum.kDatabaseLengthUnits, uom.LengthUnits)
' Sort lengths from smallest to largest.
Dim lengths As New List(Of Double) From {dir1, dir2, dir3}
lengths.Sort()
Dim minLength As Integer = lengths(0)
Dim midLength As Integer = lengths(1)
Dim maxLength As Integer = lengths(2)
' Display message with minimum rangebox size.
MessageBox.Show("Oriented Minimum Rangebox Size: " &
minLength.ToString("#.###") & " x " & midLength.ToString("#.###") & " x " & maxLength.ToString("#.###"),
"Oriented Minimum Rangebox", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Function CreateBox(partDoc As Document, surface As Object) As ClientGraphics
Dim cGraphics As ClientGraphics
cGraphics = partDoc.ComponentDefinition.ClientGraphicsCollection.Add("OrientedRangeBox")
Dim surfacesNode As GraphicsNode = cGraphics.AddNode(1)
Dim surfGraphics As SurfaceGraphics = surfacesNode.AddSurfaceGraphics(surface)
Dim targetAppearance As Asset
Try
targetAppearance = partDoc.Assets.Item("Clear - Blue")
Catch
Dim sourceAppearance As Asset = ThisApplication.AssetLibraries.Item("314DE259-5443-4621-BFBD-1730C6CC9AE9").AppearanceAssets.Item("InvGen-001-1-2") ' "Clear - Blue"
targetAppearance = sourceAppearance.CopyTo(partDoc)
End Try
surfacesNode.Appearance = targetAppearance
ThisApplication.ActiveView.Update()
Return cGraphics
End Function
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
Can't find what you're looking for? Ask the community or share your knowledge.