- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear Expert,
I want to code a bounding box for all part in the assembly but I don't want to Open part in Line: invApp.Documents.Open(oDocPartSub.FullFileName, True). I tried to change to False but it wasn't working.
Here is my Code:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
assemblyDoc = invApp.ActiveDocument
Dim oDocs As Inventor.DocumentsEnumerator
oDocs = assemblyDoc.ReferencedDocuments
For i As Integer = 1 To oDocs.Count
Dim oDocType As DocumentTypeEnum = oDocs.Item(i).DocumentType
If oDocType = DocumentTypeEnum.kAssemblyDocumentObject Then
Dim oSubDocs As Inventor.DocumentsEnumerator
oSubDocs = oDocs.Item(i).ReferencedDocuments
For ii As Integer = 1 To oSubDocs.Count
Dim oDocPartSub As Inventor.Document
oDocPartSub = oSubDocs.Item(ii)
invApp.Documents.Open(oDocPartSub.FullFileName, True)
partDoc = invApp.ActiveDocument
Dim oPartDef As Inventor.ComponentDefinition
oPartDef = partDoc.ComponentDefinition
Dim oBox As Inventor.Box = oPartDef.RangeBox
Dim dMax As Point = oBox.MaxPoint
Dim dMin As Point = oBox.MinPoint
Dim docPrec As Integer
Dim dX As Decimal = Math.Round((dMax.X - dMin.X) * 10, docPrec)
Dim dY As Decimal = Math.Round((dMax.Y - dMin.Y) * 10, docPrec)
Dim dZ As Decimal = Math.Round((dMax.Z - dMin.Z) * 10, docPrec)
Dim strThickness As Single
Dim strLength As Single
Dim strWidth As Single
Try
If dX = dY Then
strLength = dX
strWidth = dY
strThickness = dZ
End If
If dY = dZ Then
strLength = dX
strWidth = dZ
strThickness = dY
End If
If dX = dZ Then
strLength = dZ
strWidth = dY
strThickness = dX
End If
If dX > dY And dX > dZ Then
strLength = dX
If dY > dZ Then
strWidth = dY
strThickness = dZ
Else
strWidth = dZ
strThickness = dY
End If
End If
Catch ex As Exception
End Try
If dY > dX And dY > dZ Then
strLength = dY
If dX > dZ Then
strWidth = dX
strThickness = dZ
Else
strWidth = dZ
strThickness = dX
End If
End If
If dZ > dX And dZ > dY Then
strLength = dZ
If dX > dY Then
strWidth = dX
strThickness = dY
Else
strWidth = dY
strThickness = dX
End If
End If
MsgBox(strThickness & " x " & strWidth & " x " & strLength)
Next
End If
Next
End Sub
Autodesk User
Solved! Go to Solution.
