×
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

multiply selection in catscript or catvbs

multiply selection in catscript or catvbs

multiply selection in catscript or catvbs

(OP)
how can i call up this dialog? i need to select several elements and then rename them

did a search on the forum but nothing.

thanks in advance.

RE: multiply selection in catscript or catvbs

(OP)
well found a way how to call this dialog. any suggestions on renaming any selected elements with adding prefix or suffix?
i have some vba but unfortunately it's password protected.

RE: multiply selection in catscript or catvbs

Sub CATMain()

Dim oSel As Selection
Dim oSelItem As Object
Set oSel = CATIA.ActiveDocument.Selection
For i = 1 To oSel.Count
Set oSelItem = oSel.Item(i).Value
oSelItem.Name = "prefix" + oSelItem.Name + " suffix"
Next

End Sub

Eric N.
indocti discant et ament meminisse periti

RE: multiply selection in catscript or catvbs

(OP)
thanks.works fine. how can i set running number. e.g pt1 pt2 pt3 etc?

RE: multiply selection in catscript or catvbs

i suggest you try something and post your code if you have problem so we can help.

I'll try my best to help you.

Eric N.
indocti discant et ament meminisse periti

RE: multiply selection in catscript or catvbs

Use the same code but replace suffix with i

oSelItem.Name = oSelItem.Name + i

RE: multiply selection in catscript or catvbs

(OP)
thanks. but with following code i need to enter prefix several times. depends on selection. i want to enter new name just once

For i = 1 To oSel.Count
Set oSelItem = oSel.Item(i).Value
oSelItem.Name = InputBox ("prefix")+ i
Next

RE: multiply selection in catscript or catvbs

Take the input box out of the loop

sPrefix=inputbox("prefix")
For i=1 to oSel.Count
set oSelItem = oSel.Item(I).Value
oSelItem.Name = sPrefix + i
Next

RE: multiply selection in catscript or catvbs

(OP)
thanks for the answer. but this only works with digits. no wordsmad.

RE: multiply selection in catscript or catvbs


Quote (you)

how can i set running number. e.g pt1 pt2 pt3 etc?
if you give pt in the inputbox the previous code should work like a charm.

what do you mean it does not work with words?

Eric N.
indocti discant et ament meminisse periti

RE: multiply selection in catscript or catvbs

please describe what you want to do with letters

Eric N.
indocti discant et ament meminisse periti

RE: multiply selection in catscript or catvbs

(OP)
i want to enter any name. as for now if in input box i enter letters macro gives me an error. macro attached in previous post.

RE: multiply selection in catscript or catvbs

Hi,

Well, there are few modifications to be done but this is depending on what you want

CODE --> CATScript

Sub CATMain()

Dim USel As Selection
Dim InputObject(0)
Dim oStatus

InputObject(0) = "AnyObject"'selection filter forces user to select specific objects, AnyObject allows selection of any object
Set USel = CATIA.ActiveDocument.Selection

Msgbox "This macro will give you the name of a selected element, you have to select the FINISH button on the Tools Palette when you want to finish selecting" & vbCrLf & "This method work only with selection in Specification Tree"

USel.Clear'You should clear the selection before making a selection
oStatus = USel.SelectElement3(InputObject, "Select objects to list names", True,CATMultiSelTriggWhenUserValidatesSelection, False)
If (oStatus = "Cancel") Then
Exit Sub
End If

sPrefix=InputBox("String for prefix", "input", "prefix")
For i=1 to USel.Count
 USel.Item(i).Value.Name = Cstr(sPrefix) & "." & i & "_" & USel.Item(i).Value.Name 
Next

End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: multiply selection in catscript or catvbs

ok the problem you have is that you add a string and an int with +

for string manipulation I use &

if you replace your oSelItem.Name = sPrefix + i by oSelItem.Name = sPrefix & i then all is fine

Eric N.
indocti discant et ament meminisse periti

RE: multiply selection in catscript or catvbs

(OP)
thanks a lot guys for your help.

RE: multiply selection in catscript or catvbs

So that's the difference between + and &. They seem to be interchangeable except in this case...thanks:) star for itsmyjob

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