Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Selecting the items you just pasted via script?

Status
Not open for further replies.

puck

Aerospace
Nov 9, 2001
61
I'm writing a script that lets me select a product or part to copy and paste and then translate them.
The problem I'm running into is getting the items that I just pasted as my selction to translate.
Here is an example of the code and the part that I'm having trouble is where I Set product2 = ?????

<code>

Dim Sel1(0)
Sel1(0) = "Product"

Dim Done As Integer
Dim vbYes As Constants
Dim vbNo As Constants

vbYes = 6
vbNo = 7
Done = vbYes

Do While Done = vbYes
ProdDoc.Activate

Dim SelObject As Object


Set Selection1 = ProdDoc.Selection

Selection1.Clear
vRet = Selection1.SelectElement(Sel1, "Select the Part or Product to Copy.", True)
Set SelObject = Selection1.Item(1)
Set CurProd = SelObject.Value
MsgBox CurProd.Nomenclature
ProdDoc.Selection.Add(CurProd)

Selection1.Copy

ProdDoc.Activate

Selection1.Clear
Selection1.Add Prod
Selection1.Paste

Prod.Update

Selection1.Clear

Dim product2 As Product
Set product2 = ?????

Dim move1 As Move
Set move1 = product2.Move

</code>

Any ideas?
TIA,
Puck
 
Replies continue below

Recommended for you

Hello there puck.

I guess the latest product/part will be at the bottom of the tree, so you could use a Count property of all your Product's parts or products, and the last pasted part/product would be the one you want.
Haven't tried this myself though...

-bjod
 
Yeah I've tried that method allready but itdoesn't seem to work in this case.
I tried
<code>

Dim product2 As Product
Set product2 = Prods.Count
</code>
Prods was set prior in the script As Products of the top level product.

Thanks for the try though,
Puck
 
Doh,
Went back and looked at that again and it does work just had to set the item number first.

t = Prods.Count

Dim product2 As Product
Setproduct2 = Prods.Item(t)

Thanks again,

Still hitting myself over the head.
LOL,
Puck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor