×
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

Selecting the items you just pasted via script?

Selecting the items you just pasted via script?

Selecting the items you just pasted via script?

(OP)
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

RE: Selecting the items you just pasted via script?

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

RE: Selecting the items you just pasted via script?

(OP)
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

RE: Selecting the items you just pasted via script?

(OP)
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

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