Copy from a search and paste on first selection
Copy from a search and paste on first selection
(OP)
I have a first selected item.
Then i perform a search-select-copy in the whole document, i copy, and i would like to paste in the first selection, but i cant find the metod
to recall the first selection.
Sub CATMain()
Dim objSel As Selection
Dim objSel2 As Selection
Set objSel2 =CATIA.ActiveDocument.Selection
Set objSel =CATIA.ActiveDocument.Selection
objSel.Search "name=*ITEMTOCOPY*,all"
objSel.Copy
End Sub
I NEED TO PASTE THE objSel in the objSel2
Sorry for the noob question :) !
Then i perform a search-select-copy in the whole document, i copy, and i would like to paste in the first selection, but i cant find the metod
to recall the first selection.
Sub CATMain()
Dim objSel As Selection
Dim objSel2 As Selection
Set objSel2 =CATIA.ActiveDocument.Selection
Set objSel =CATIA.ActiveDocument.Selection
objSel.Search "name=*ITEMTOCOPY*,all"
objSel.Copy
End Sub
I NEED TO PASTE THE objSel in the objSel2
Sorry for the noob question :) !





RE: Copy from a search and paste on first selection
set myfirstselectionobject = catia.activedocument.selection.item(1).value
dim objsel as selection
[..]
objsel.copy
objsel.clear
objsel.add myfirstselectionobject
objsel.paste
indocti discant et ament meminisse periti
RE: Copy from a search and paste on first selection
Sub CATMain()
Dim objSel2 As Selection
Dim myfirstselectionobject
set myfirstselectionobject = CATIA.ActiveDocument.Selection.Item(1).Value
Dim objSel as Selection
Set objSel =CATIA.ActiveDocument.Selection
objSel.Search "name=Pal_DX,all"
objSel.copy
objSel.clear
objSel.add myfirstselectionobject
objSel.paste
End Sub
If i play this the first time, this is working without any problem. The second and thirtd etc.. the Pal_DX is copied multiple times.
What i should tell the program is to copy or paste just the first result of the selection. I think the item(1) pointer should be added somewhere.
RE: Copy from a search and paste on first selection
unless you rename the elements after paste them...
indocti discant et ament meminisse periti
RE: Copy from a search and paste on first selection
But i think is easyer the first metod. I think is the Item2 command i am searching for. Though i cant understand it's using.
RE: Copy from a search and paste on first selection
Sub CATMain()
Dim objSel2 As Selection
Dim myfirstselectionobject
set myfirstselectionobject = CATIA.ActiveDocument.Selection.Item(1).Value
Dim objSel as Selection
Set objSel =CATIA.ActiveDocument.Selection
objSel.Search "name=Pal_DX,all"
set objSel2 = CATIA.ActiveDocument.Selection.Item(1).Value
objSel.clear
objSel.add objSel2
objSel.copy
objSel.clear
objSel.add myfirstselectionobject
objSel.paste
End Sub