Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1665 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  [Macro Catia ] Rename all instances and references

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Macro Catia ] Rename all instances and references

n°2229120
mahinfo
Posté le 26-05-2014 à 15:55:48  profilanswer
 

Hello ,
 
I try to write a macro to rename all instances and references in an assembly.
I find some subjects in this forum about the same problem but I can't rename all the assembly tree.
This is the macro :
 
***************
 
Sub CATMain()
 
 
Dim Input1 , Input2 As string
 
Set productDocument1 = CATIA.ActiveDocument
 
If InStr(CATIA.ActiveDocument.Name, ".CATProduct" ) < 1 Then
MsgBox "Error: Active CATIA Document is not a Product", , msgboxtext
Exit Sub
End If
 
Input1 = InputBox("Old string ","Modify name" )
If (Input1=False) Then  
Exit Sub
Else
Input2= InputBox("Replace <"&Input1&"> with :","Modify name" )
End If
 
If (Input2=False) Then
Exit Sub
Else
Call ReplaceString(productDocument1.Product)
End If
 
 
 
End Sub
 
Sub ReplaceString(actif_prod)
 
If actif_prod.Products.Count > 0 Then
 
 
actif_prod.ReferenceProduct.PartNumber = Replace(actif_prod.ReferenceProduct.PartNumber,Input1,Input2)
 
 
actif_prod.Name = Replace(actif_prod.Name,Input1,Input2)
 
 
For i = 1 To actif_prod.Products.Count
 
 
Call ReplaceString(actif_prod.Products.Item(i))
Next
 
Else  
 
actif_prod.ReferenceProduct.PartNumber = Replace(actif_prod.ReferenceProduct.PartNumber,Input1,Input2)
 
actif_prod.Name = Replace(actif_prod.Name,Input1,Input2)
 
 
End If
 
End Sub  
 
 
***********************
 
I have a tree like this :
 
1.documentname
--1.1.PartNumber (partname 1) ---> simple part
-----1.1.1 PartNumber
--1.2.PartNumber (Name) ---> product (sub-assembly)
-----1.2.1PartNumber (partName 2)
---------3.1.1 PartNumber
 
The macro can't rename partName 2. It can rename all others.
Can someone help me please ?
Thanks a lot.

mood
Publicité
Posté le 26-05-2014 à 15:55:48  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  [Macro Catia ] Rename all instances and references

 

Sujets relatifs
macro code arduinoXcopy et rename problème
Macro VBA utilisant 2 WorkbooksExécuter une macro au changement du contenu d'une cellule sous excel
MACRO REGROUPERMacro avec mail automatique
Macro cpier/coller differents ongletsmacro dans power point. Qui sait ?
probleme sur replace dans une macroMacro pour faire un calendrier excel
Plus de sujets relatifs à : [Macro Catia ] Rename all instances and references


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR