Renomer un Product en VB dans CATIA

Renomer un Product en VB dans CATIA - Infographie 3D - Graphisme

Marsh Posté le 26-06-2013 à 15:05:10    

Bonjour,  
 
Nouvelle macro nouveau probleme    
 
Voila j ai une macro qui me change le nom de mes WP et Part mais elle n agit pas dans les WP de niveau inferieur alors quelle les identifies.
   
Mon Code :  
 
Sub catia_models_list()  
           
Dim objRootProductDoc As ProductDocument  
Dim mySel As Selection  
Dim myProduct As Product  
Dim i As Integer  
         
        Set objRootProductDoc = CATIA.ActiveDocument  
        Set mySel = CATIA.ActiveDocument.Selection  
         
    mySel.Search ("'Assembly Design'.Product,sel" )  
         For i = 1 To mySel.Count  
         Set myProduct = mySel.Item(i).Value  
         Set product2 = myProduct.Item  
                 
                If Right(myProduct.Name, 2) Like ".*" Then  
                lenght = Len(myProduct.Name) - 2  
                string1 = Left(myProduct.Name, lenght)  
               ' string1 = myProduct.Name  
 
myProduct.Name = string1  
 
        End If  
    Next  
 
End Sub  
 
Si quelqu un a une solution ...  
 
 
Cordialement ...  
 
olivier

Reply

Marsh Posté le 26-06-2013 à 15:05:10   

Reply

Marsh Posté le 06-09-2013 à 13:25:24    

Bonjour,
 
Il faut bidouiller pour renommer les product ou part qui ne sont pas au premier niveau. J'ai eu le même problème hier.

Spoiler :

Sub catia_models_list()  
           
Dim objRootProductDoc As ProductDocument  
Dim mySel As Selection  
Dim myProduct As Product  
Dim i As Integer  
 
 
Dim ProductDoc As productDocument 'document incluant le product voulu
Dim ProductParent As Product 'product incluant le product voulu
Dim ProductParentProds As products 'collection de products du ProductParent
Dim ProductObject As Product 'le product voulu

 
        Set objRootProductDoc = CATIA.ActiveDocument  
        Set mySel = CATIA.ActiveDocument.Selection  
         
    mySel.Search ("'Assembly Design'.Product,sel" )  
         For i = 1 To mySel.Count  
         Set ProductDoc = mySel.Item(i).Value.Parent.Parent.ReferenceProduct.Parent
         Set ProductParent = ProductDoc.Product
         Set ProductParentProds = ProductParent.products
         Set ProductObject = ProductParentProds.Item(mySel.Item(i).Value.name)

 
         If Right(ProductObject.Name, 2) Like ".*" Then  
                lenght = Len(ProductObject.Name) - 2  
                string1 = Left(ProductObject.Name, lenght)  
               ' string1 = ProductObject.Name  
          ProductObject.Name = string1  
 
        End If  
    Next  
 
End Sub


 
Quelque chose dans ce genre là.


Message édité par ptittom le 06-09-2013 à 13:26:16
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed