Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Member Login

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Eng-Tips
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I love this site! It's so nice to know that there are so many people out there who are willing to share their knowledge..."

Geography

Where in the world do Eng-Tips members come from?
FTARunner (Automotive)
12 Sep 12 13:16
In short, I need a macro to search through the whole assembly in Catia V5 and rename or remove *.1 from the instance name.

I got up to a point where I was able to search the whole assembly, select all the parts with a *.1, but it looks for that specific part name.

Any ideas?
ferdo (Mechanical)
13 Sep 12 9:11
Hi,

Can you post what you have now (code) and a picture with what you want in fact?

I think I know what you want but just to be sure (rename is a little bit different then remove...)

Regards
Fernando

https://picasaweb.google.com/102257836106335725208

FTARunner (Automotive)
13 Sep 12 9:22
Just to update; I got a macro that renamed the instance name to be the same as the part name. That works great but I wasn't looking at the whole problem.

Basic: I need a macro that will remove spaces from the part name (and instance name if able). So for example; DVR Front Door Lower Ring will change to DVRFrontDoorLowerRing.

I usually get rather large assemblies and we have to take these assemblies into another program. When it converts the geometry, it changes any spaces and periods to underscores and I end up having to go through all the part names and change them.

This is the macro. I did change a little bit, so there might be a line that is irrelevant or useless.


Sub CATMain()
Language="VBSCRIPT"

Set Documents = CATIA.documents

For Each Item In Documents

If Right(item.Name, 10) = "CATProduct" Then

Set CurrentProduct = item.Product.Products

For i = 1 To CurrentProduct.count

CurrentPartNumber = CurrentProduct.item(i).PartNumber

k = 1

For j = 1 to CurrentProduct.count

CurrentLine = CurrentProduct.item(j).PartNumber

If CurrentLine = CurrentPartNumber Then

CurrentProduct.item(j).Name = CurrentPartNumber

k = k + 1

End If

Next

Next

End If

Next

End Sub
ferdo (Mechanical)
15 Sep 12 0:35
Hi

To replace a string (in your case a blank space) only in PartNumber you can use in a CATScript


Language="VBSCRIPT"

Sub CATMain()

Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products

Dim StrToBeReplaced
Dim sLF
sLF = Chr(10)

StrToBeReplaced = InputBox("Write here string to be replaced", "Input for String to be replaced", "A string", vbOKCancel)
If StrToBeReplaced = False Then
Exit Sub
End If

Dim StrUsedForReplace
StrUsedForReplace = InputBox("Write here string to be used for replace", "Input for String to be used for replace", "A string", vbOKCancel)
If StrUsedForReplace = False Then
Exit Sub
End If

For i = 1 To products1.Count

ElementNumber = products1.Item(i).Partnumber ' Extract reference number
ElementNumberReplaced = Replace(ElementNumber, StrToBeReplaced, StrUsedForReplace)
products1.Item(i).Partnumber = ElementNumberReplaced

Next

End Sub

Regards
Fernando

https://picasaweb.google.com/102257836106335725208

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!

Back To Forum

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close