09-19-2024
11:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-19-2024
11:38 AM
I'm trying to get a rangebox on a part in an assembly, but in the assemblies coordinate system. Does anyone know how to do this?
Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oOcc as ComponentOccurance
oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Pick a feature")
xFrameL = oOcc.Definition.RangeBox.MaxPoint.X - oOcc.Definition.RangeBox.MinPoint.X
The code above works great to get the rangebox on the PART coordinate system but I need one for an assembly coordinate system.
Solved! Go to Solution.
09-19-2024
11:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-20-2024
01:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-20-2024
01:14 AM
Be careful because it works until the part is not rotated in assembly.
09-20-2024
03:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-20-2024
03:44 AM
I never could get the oriented range box working, could you post a sample code?
09-20-2024
05:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-20-2024
05:11 AM
This is a sample, how you can work with OrientedBox of part in assembly context
Sub Main()
Dim asm As AssemblyDocument = ThisDoc.Document
Dim asmDef As AssemblyComponentDefinition = asm.ComponentDefinition
Dim partOcc As ComponentOccurrence = asmDef.Occurrences(1)
Dim partDef As PartComponentDefinition = partOcc.Definition
Dim orientedBox As OrientedBox = partDef.OrientedMinimumRangeBox
PrintBoxData(orientedBox, "In part")
TransformBy(orientedBox, partOcc.Transformation)
PrintBoxData(orientedBox, "In assembly")
End Sub
Private Sub TransformBy(orientedBox As OrientedBox, matrix As Matrix)
Dim cornerPoint As Point
Dim directionOne As Vector
Dim directionTwo As Vector
Dim directionThree As Vector
orientedBox.GetOrientedBoxData(cornerPoint, directionOne, directionTwo, directionThree)
cornerPoint.TransformBy(matrix)
directionOne.TransformBy(matrix)
directionTwo.TransformBy(matrix)
directionThree.TransformBy(matrix)
orientedBox.PutOrientedBoxData(cornerPoint, directionOne, directionTwo, directionThree)
End Sub
Private Sub PrintBoxData(orientedBox As OrientedBox, Optional title As String = "")
Dim stringBuilder As New System.Text.StringBuilder
stringBuilder.AppendLine(title)
stringBuilder.AppendLine(String.Format("CornerPoint{3}[{0:N2}, {1:N2}, {2:N2}]", orientedBox.CornerPoint.X, orientedBox.CornerPoint.Y, orientedBox.CornerPoint.Z, vbTab))
stringBuilder.AppendLine(String.Format("DirectionOne{3}[{0:N2}, {1:N2}, {2:N2}]", orientedBox.DirectionOne.X, orientedBox.DirectionOne.Y, orientedBox.DirectionOne.Z, vbTab))
stringBuilder.AppendLine(String.Format("DirectionTwo{3}[{0:N2}, {1:N2}, {2:N2}]", orientedBox.DirectionTwo.X, orientedBox.DirectionTwo.Y, orientedBox.DirectionTwo.Z, vbTab))
stringBuilder.AppendLine(String.Format("DirectionThree{3}[{0:N2}, {1:N2}, {2:N2}]", orientedBox.DirectionThree.X, orientedBox.DirectionThree.Y, orientedBox.DirectionThree.Z, vbTab))
Logger.Debug(stringBuilder.ToString())
End Sub