Convertir IPT en RFA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Bonjour,
Je cherche à convertir plusieurs fichiers IPT qui se trouvent dans un dossier en RFA.
J'ai trouvé sur le forum le code ci-dessous avec indicateur d'avancement mais j'ai l'erreur qui suit:
Imports System.Windows.Forms
Sub Main
Dim oDlg As New FolderBrowserDialog
oDlg.Description = "Select folder to save RFA-files"
oDlg.ShowDialog
If oDlg.SelectedPath = "" Then Exit Sub
Dim oPath As String = oDlg.SelectedPath
Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
If MsgBox("Do you want to continue?", vbOKCancel + vbExclamation, "Batch Create RFA") = vbCancel Then Exit Sub
Dim oCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oLeafOccs As ComponentOccurrencesEnumerator = oCompDef.Occurrences.AllLeafOccurrences
Dim oTotal As Integer = oLeafOccs.Count
Dim oProgressBar As Inventor.ProgressBar = ThisApplication.CreateProgressBar(False, oTotal, "Exporting to RFA", False)
ThisApplication.UserInterfaceManager.DoEvents
oAsmDoc.ComponentDefinition.RepresentationsManager.ActiveDesignViewRepresentation.HideAll
Dim oBIMcomponent As BIMComponent = oCompDef.BIMComponent
Dim i As Integer = 1
Dim oOcc As ComponentOccurrence
For Each oOcc In oLeafOccs
oOcc.Visible = True
Dim oOccName As String = oOcc.Name.Replace(":", "_")
Dim FullFileName As String = oPath & "\" & oOccName & ".rfa"
oProgressBar.Message = "Exporting " & FullFileName & " (" & i & "/" & oTotal & ")"
oProgressBar.UpdateProgress
ThisApplication.UserInterfaceManager.DoEvents
oBIMcomponent.ExportBuildingComponent(FullFileName)
oOcc.Visible = False
i += 1
Next
oProgressBar.Close
oAsmDoc.ComponentDefinition.RepresentationsManager.ActiveDesignViewRepresentation.ShowAll
End Sub
ERREUR:
Erreur de règle: Generate_RFA, dans le document TEST_RULES.0019.ipt
Impossible d'effectuer un cast d'un objet COM de type 'Inventor._DocumentClass' en type d'interface 'Inventor.AssemblyDocument'. Cette opération a échoué, car l'appel QueryInterface sur le composant COM pour l'interface avec l'IID '{29F0D465-C114-11D2-B77F-0060B0F159EF}' a échoué en raison de l'erreur suivante : Cette interface n’est pas prise en charge (Exception de HRESULT : 0x80004002 (E_NOINTERFACE)).
Pourriez-vous m'indiquer comment résoudre ce problème svp?
Le but est d'éviter de faire la conversion pour chaque fichier.
Merci d'avance pour vos lumières