| |
 | Die Gewinne der Zukunft werden mit intelligenten, autonomen Elektrofahrzeugen eingefahren. (3DEXPERIENCE) |
Autor
|
Thema: How to list out unloaded parts/products? (237 mal gelesen)
|
Sylas Mitglied
 
 Beiträge: 322 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 24. Jan. 2023 12:16 <-- editieren / zitieren --> Unities abgeben:         
Hello Is it possible to list out all unloaded parts/products? How can I add to selection all elements which have "unloaded" comment in "Link to reference" section on Properties page? Best regards Lucas
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
       
 Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 24. Jan. 2023 14:33 <-- editieren / zitieren --> Unities abgeben:          Nur für Sylas
Hi Lucas You could check, if a/some properties of the instance is accessible/not empty (e.g. Nomenclature, GetDefaultShapeName, ...). If so, the instance is not unloaded. Regards, Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sylas Mitglied
 
 Beiträge: 322 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 24. Jan. 2023 14:58 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von bgrittmann: Hi LucasYou could check, if a/some properties of the instance is accessible/not empty (e.g. Nomenclature, GetDefaultShapeName, ...). If so, the instance is not unloaded. Regards, Bernd
Hello Bernd But that would give me loaded parts not unloaded ones Still I wouldn't have unloaded parts names, right? If it's not loaded - how can I retrive those infos? They are not in Documents collection, so how to get that? Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
       
 Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 24. Jan. 2023 15:28 <-- editieren / zitieren --> Unities abgeben:          Nur für Sylas
|
Randle Mitglied CAD/PLM Consultant
  
 Beiträge: 695 Registriert: 12.04.2003 Win10 x64 CATIA V5 R18, R19, R21, R27-29
|
erstellt am: 24. Jan. 2023 16:57 <-- editieren / zitieren --> Unities abgeben:          Nur für Sylas
Hello together, check this out, that should work: Code:
Public CollectionOfUnloadedFiles As New Collection Sub CATmain()Dim RootProdDoc As ProductDocument Dim RootProd As Product On Error GoTo NoProductActive Set RootProdDoc = CATIA.ActiveDocument On Error GoTo 0 Set RootProd = RootProdDoc.Product RecursivStructureScan RootProd If CollectionOfUnloadedFiles.Count = 0 Then MsgBox "All files loaded!", vbInformation, "Finish!" Else MsgBox "Some files are not loaded!" & vbNewLine & BuildStringForMessage(CollectionOfUnloadedFiles), vbInformation, "Finish!" End If Exit Sub '----------- NoProductActive: MsgBox "No active product loaded!", vbInformation, "Program abort!" End Sub Private Sub RecursivStructureScan(t_Prod As Product) Dim CurrentProd As Product For Each CurrentProd In t_Prod.Products If IsLoaded(CurrentProd) Then If TypeName(CurrentProd.ReferenceProduct.Parent) = "ProductDocument" Then RecursivStructureScan CurrentProd End If Next End Sub Private Function IsLoaded(t_ProdToCheck As Product) As Boolean Dim CheckProd As Product IsLoaded = True On Error Resume Next Set CheckProd = t_ProdToCheck.ReferenceProduct If CheckProd Is Nothing Then AddToCollection t_ProdToCheck.name IsLoaded = False End If On Error GoTo 0 End Function Private Sub AddToCollection(value As String) Dim i As Integer If InStr(1, value, ".", vbTextCompare) <> 0 Then value = Left(value, InStrRev(value, ".", -1, vbTextCompare) - 1) End If For i = 1 To CollectionOfUnloadedFiles.Count If CollectionOfUnloadedFiles.Item(i) = value Then Exit Sub Next CollectionOfUnloadedFiles.Add value End Sub Private Function BuildStringForMessage(col As Collection) As String Dim i As Integer If CollectionOfUnloadedFiles.Count > 0 Then For i = 1 To CollectionOfUnloadedFiles.Count BuildStringForMessage = BuildStringForMessage & vbNewLine & CollectionOfUnloadedFiles.Item(i) Next Exit Function End If End Function
BR Randle ------------------ Wer für nichts steht, fällt für alles! [Diese Nachricht wurde von Randle am 24. Jan. 2023 editiert.] Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sylas Mitglied
 
 Beiträge: 322 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 31. Jan. 2023 15:11 <-- editieren / zitieren --> Unities abgeben:         
Hello Randle Your code works perfect! Thank you very much Would it be possible to export the
CollectionOfUnloadedFiles to txt file or somewhere else from where I could copy the names? Like List window from where I could copy it instead of Msgbox? Best regards Lucas Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
       
 Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 31. Jan. 2023 15:34 <-- editieren / zitieren --> Unities abgeben:          Nur für Sylas
Hi Lucas Yes it should be possible: e.g. open a Textstream (see here), loop trough the collection and write a line with the item (name) Regards, Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sylas Mitglied
 
 Beiträge: 322 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 31. Jan. 2023 15:41 <-- editieren / zitieren --> Unities abgeben:         
Hello Bernd I've tried following:
Code:
Private Function BuildStringForMessage(col As Collection) As String Dim i As Integer If CollectionOfUnloadedFiles.Count > 0 Then Set fs = CreateObject("Scripting.FileSystemObject") Set A = fs.CreateTextFile("c:\testfile.txt", True) For i = 1 To CollectionOfUnloadedFiles.Count A.WriteLine (CollectionOfUnloadedFiles.Item(i)) Next Exit Function End If End Function
but I get "Compile error: Expected expression" at the line:
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
Can you point me what did I wrong? Gruß Lucas Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
       
 Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 31. Jan. 2023 15:56 <-- editieren / zitieren --> Unities abgeben:          Nur für Sylas
|
Sylas Mitglied
 
 Beiträge: 322 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 31. Jan. 2023 16:15 <-- editieren / zitieren --> Unities abgeben:         
|