Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

multiply selection in catscript or catvbs 1

Status
Not open for further replies.

JeniaL

Mechanical
Jun 3, 2014
547
IL
how can i call up this dialog? i need to select several elements and then rename them
download.aspx

did a search on the forum but nothing.

thanks in advance.
 
Replies continue below

Recommended for you

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.
 
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
 
thanks.works fine. how can i set running number. e.g pt1 pt2 pt3 etc?
 
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
 
Use the same code but replace suffix with i

oSelItem.Name = oSelItem.Name + i
 
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
 
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
 
thanks for the answer. but this only works with digits. no words[mad].

 

you said:
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
 
please describe what you want to do with letters

Eric N.
indocti discant et ament meminisse periti
 
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.
 
Hi,

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

Code:
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

- Romania
- EU
 
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
 
So that's the difference between + and &. They seem to be interchangeable except in this case...thanks:) star for itsmyjob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top