Well, if you need to, you can try this (iLogic):
Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim FB As New System.Windows.Forms.OpenFileDialog()
FB.InitialDirectory = ThisDoc.Path
FB.Filter = "*.ipt;*.iam|*.ipt;*.iam"
FB.Multiselect = True
FB.ShowDialog()
If FB.FileNames.Length = 0 Then Exit Sub
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oMatrix As Matrix = oTG.CreateMatrix
Call oMatrix.SetToRotation(3.14159265358979 / 4, oTG.CreateVector(0, 0, 1), oTG.CreatePoint(0, 0, 0))
Call oMatrix.SetTranslation(oTG.CreateVector(1, 2, 1), True)
ThisApplication.SilentOperation = True
ThisApplication.ScreenUpdating = False
For Each sFile As String In FB.FileNames
Try
oDoc.ComponentDefinition.Occurrences.Add(sFile, oMatrix)
Catch
End Try
Next
ThisApplication.ScreenUpdating = True
ThisApplication.SilentOperation = False
ThisApplication.ActiveView.Update()
Or the same in VBA:
Public Sub PlaceDocument()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
Exit Sub
End If
Dim sPath As String
sPath = oDoc.FullFileName
Dim iFP As Integer
iFP = InStrRev(sPath, "\", -1)
sPath = Microsoft.VisualBasic.Left(sPath, iFP - 1)
Dim FB As New System.Windows.Forms.OpenFileDialog()
FB.InitialDirectory = sPath
FB.Filter = "*.ipt;*.iam|*.ipt;*.iam"
FB.Multiselect = True
FB.ShowDialog()
If FB.FileNames.Length = 0 Then
Exit Sub
End If
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
Dim oMatrix As Matrix
Set oMatrix = oTG.CreateMatrix
Call oMatrix.SetToRotation(3.14159265358979 / 4, oTG.CreateVector(0, 0, 1), oTG.CreatePoint(0, 0, 0))
Call oMatrix.SetTranslation(oTG.CreateVector(1, 2, 1), True)
ThisApplication.SilentOperation = True
ThisApplication.ScreenUpdating = False
On Error Resume Next
For Each sFile As String In FB.FileNames
oDoc.ComponentDefinition.Occurrences.Add(sFile, oMatrix)
Next
ThisApplication.ScreenUpdating = True
ThisApplication.SilentOperation = False
ThisApplication.ActiveView.Update()
End Sub
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods