Message 1 sur 5

Non applicable
10-10-2019
09:45 AM
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Lien permanent
- Imprimer
- Signaler
Bonjour,
Je cherche à exporter les éléments contenus dans un assemblage, mais uniquement dans le 1er niveau. Je ne veux pas exporter l'ensemble des parts. J'ai trouvé plusieurs topic qui traitent du sujet, mais à chaque fois cela exporte l'ensemble de l'arbre.
Avec un bout de code trouvé réalisé par @ThomasB44 j'ai réussi à faire ce que je veux sauf que le premier fichier n'a pas de nom et les suivants sont décallé...
Une idée de ce que j'ai mal fait ?
Sub Main 'Variables Dim oDoc As Inventor.AssemblyDocument oDoc = ThisDoc.Document Dim oOcc As ComponentOccurrence Dim oOccCol As Inventor.ObjectCollection oOccCol = ThisApplication.TransientObjects.CreateObjectCollection Dim oFile As String 'Library Dim oAsset As Asset '- - - - - - - - - - - - -STEP setup - - - - - - - - - - - - oPath = ThisDoc.Path 'get STEP target folder path oFolder = oPath & "\" & oAsmName & " STEP Files" 'Check for the step folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'check for selection Dim oSelSet As SelectSet oSelSet = oDoc.SelectSet If oSelSet.Count = 0 Then While True 'Ask user for a selection oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a component :") If IsNothing(oOcc) Then Exit While 'Add component to collection oOccCol.Add(oOcc) End While 'Add collection to selection oDoc.SelectSet.SelectMultiple(oOccCol) oSelSet = oDoc.SelectSet End If 'Loop through collection For Each oOcc In oSelSet oFile = oOcc.ReferencedDocumentDescriptor.FullDocumentName Dim oCurFile As Document oCurFile = ThisApplication.Documents.Open(oFile, True) oCurFile.SaveAs(oFolder & "\" & ShortName & (".stl"), True) oCurFileName = oCurFile.FullFileName 'defines backslash As the subdirectory separator Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar 'find the postion of the last backslash in the path FNamePos = InStrRev(oCurFileName, "\", -1) 'get the file name with the file extension Name = Right(oCurFileName, Len(oCurFileName) - FNamePos) 'get the file name (without extension) ShortName = Left(Name, Len(Name) - 4) If ThisDoc.Document.ComponentDefinition.BOMStructure <> BOMStructureEnum.kPurchasedBOMStructure Then Try oCurFile.SaveAs(oFolder & "\" & ShortName & (".stl") , True) Catch MessageBox.Show("Error processing " & oCurFileName, "ilogic") End Try oCurFile.Close Else oCurFile.Close End If Next End Sub
Résolu ! Accéder à la solution.