×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • 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!
  • Students Click Here

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Instance name alteration Macro in CATIA V5

Instance name alteration Macro in CATIA V5

Instance name alteration Macro in CATIA V5

(OP)
Hi everyone,

I need to make a macro to alter the instance name of selected accessories in several assemblies and sub assemblies using input boxes in CATIA V5. i'm fairly new to CATIA and CATScript and need help with this macro because it doesn't work in sub assemblies.
Can someone please help me?
I've gotten this far using the internet and several macros that i found and tweaked. and this thread really helped me thread560-340850: Macro to Change Part Number and Instance Name to File Name, but i can't go any further on my own.
The macro is written in CATScript.
Thanks in advance.

Sub CATMain()

Dim oSelection As Selection
Set oSelection = CATIA.ActiveDocument.Selection

If oSelection.Count < 1 then
MsgBox "Pick some ejectors using cad selection."

Else

'****** Inputbox for Instance name alteration *****
Dim NewIName As String
NewIName = InputBox("Please input the desired Instance Name. Example: E","Instance name alteration","E")

'****** Inputbox for instance number increment *****
Dim NewINumber As Integer
NewINumber = InputBox("Please input the initial number for the 1st ejector. Example: 1","Instance numbering alteration","1")

Dim oBody
Dim InstName As Body

For oBody = 1 to oSelection.Count
Set InstName = oSelection.Item(oBody).Value

'****** Instance name alteration *****
InstName.Name= NewIName & NewINumber
NewINumber=NewINumber+1
Next

End if

End Sub

RE: Instance name alteration Macro in CATIA V5

your code seems to work on selection only, if you want it to work on non selected sub assembly of selected element you have to include more (recursive) code. Check the ListingNames sub in the example you mentioned.

inside your

CODE --> code

For oBody = 1 to oSelection.Count
[...]
next 
you could include a call to a recursive sub...

Eric N.
indocti discant et ament meminisse periti

RE: Instance name alteration Macro in CATIA V5

(OP)
@itsmyjob

thanks for your reply.
I've tried to include the recursive more recursive code, but i can't seem to work it out.
Can you help me with this?

RE: Instance name alteration Macro in CATIA V5

(OP)
@drewmumaw

I've looked at your thread but as i mentioned in my original post i don't know where or even what to include in my code.
Can you please help me?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

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!


Resources