Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

MACRO: Publication renaming

Status
Not open for further replies.

spe88

Automotive
Jul 17, 2016
15
Hello,

I tried to find a macro, which can rename all the publication to the name what it gets its reference from.

e.g.:

sketch name: RW_Mastersketch
publication name: RW_Sketch

I wanna run a macro which rename it to RW_Mastersketch.

Could I have the code of it, it seems not so difficult, but I am not skilled at programming.

Thank you
 
Replies continue below

Recommended for you

in CATIA publication options (tools-publications) you can opt for this behaviour...

regards,
LWolf
 
Has it worked for you? I tried it, I set it to rename always, but nothing happens when I rename the reference. The publication keeps its original name.
 
it is for creating the publications... once created the feature will get the name of the publication. but it is not meant to work after that.

regards,
LWolf
 
but yes, it is possible to achieve what you are looking for.

regards,
LWolf
 
There is a permanent restriction in CATIA that doesn't allow you to rename a publication with code :(. "THIS PROBLEM IS PERMANENT RESTRICTION IN CATIA" See --> HD94249: IMPOSSIBLE TO RENAME A PUBLICATION WITH VB AUTOMATION, The following code will rename the published elements to match the publication, which is less desirable, but does ensure that they match.

Sub publishElementRenam()
Dim uSel As Selection
Set uSel = CATIA.ActiveDocument.Selection

If uSel.Count = 0 Then
MsgBox "Please select a product to rename references for then run again.", , "Error"
Exit Sub
End If

If TypeName(uSel.Item(1).Value) <> "Product" Then
MsgBox "Please select a product to rename references for then run again.", , "Error"
Exit Sub
End If

Dim uPubs As Publications
Set uPubs = uSel.Item(1).Value.Publications

If uPubs.Count = 0 Then
MsgBox "Selected product has no references.", , "Error"
Exit Sub
End If

Dim i As Integer
For i = 1 To uPubs.Count
Dim uPub As Publication
Set uPub = uPubs.Item(i)

uSel.Clear
uSel.Add uPub.Valuation

uSel.Item(1).Value.Name = uPub.Name

Next

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor