×
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

PasteSpecial As Result CATVBA not working

PasteSpecial As Result CATVBA not working

PasteSpecial As Result CATVBA not working

(OP)
Has anyone had any issues with "CATPrtResultWithOutLink" to paste "AsResult" not working? I'm trying to paste a product into a newly created product but nothing gets pasted in. Using "CATPrtCont" to paste "As Specified In Part Document" results in an error.

here is a quick example code:

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim productDocument1 As Document
Set productDocument1 = documents1.Add("Product")

Dim product1 As Product
Set product1 = productDocument1.Product
product1.PartNumber = "MyNewProduct"


Dim oSel 'As Selection
Set oSel = CATIA.ActiveDocument.Selection

oSel.Add partCol.Item(i)
oSel.Copy

Dim newSel 'As Selection
Set newSel = productDocument1.Selection

newSel.Clear
newSel.Add product1

newSel.PasteSpecial "CATPRTResultwithoutlink"

'newSel.paste
'newSel.PasteSpecial "CATPrtResult"
'newSel.PasteSpecial "CATProdCont"
newSel.Clear
oSel.Clear

RE: PasteSpecial As Result CATVBA not working

what is partCol.Item(i)?

Eric N.
indocti discant et ament meminisse periti

RE: PasteSpecial As Result CATVBA not working

(OP)
This was only a snippet of the code but basically I have the user select some data and add it to a collection, then the user could select more data and is added to the collection. Then the collection is copied and pasted into the new product.

http://excelspreadsheetshelp.blogspot.com - http://scripting4v5.com

RE: PasteSpecial As Result CATVBA not working

do you add osel.item(x).value to the collection and you have product in your collection or you add osel.item(x) to the collection and you have selectedelement in your collection ?

what is partCol.Item(i)?

Eric N.
indocti discant et ament meminisse periti

RE: PasteSpecial As Result CATVBA not working

(OP)
Here is the full code to show how the parts are selected by a user, added to a collection, then hopefully copied and pasted into a newly created product.

'filter what to select
Dim filter(0)
filter(0) = "Part"

'select the parts
Dim theOldPart As String

Dim partSelection
Set partSelection = CATIA.ActiveDocument.Selection
partSelection.Clear

theOldPart = partSelection.SelectElement2(filter, "Select the Old Part or hit ESC to cancel.", False)

If theOldPart <> "Normal" Then

MsgBox "ERROR: Problem with the selection. Cancelling the program.", vbCritical, "No CATPart Selected."

Exit Sub
Else
End If

'--save the old part in a collection for use later
Dim partCol As Collection
Set partCol = New VBA.Collection

partCol.Add partSelection.Item2(1).Value

'-----------create new product-------
Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim productDocument1 As Document
Set productDocument1 = documents1.Add("Product")

Dim product1 As Product
Set product1 = productDocument1.Product
product1.PartNumber = "Compare" & VBA.Format(Now(), "yyyymmddHhNnSs")

Dim OldPartData
Set OldPartData = partCol.Item(1)

Dim i As Integer

For i = 1 To partCol.Count

Dim oSel 'As Selection
Set oSel = CATIA.ActiveDocument.Selection

oSel.Add partCol.Item(i)
oSel.Copy

Dim newSel 'As Selection
Set newSel = productDocument1.Selection

newSel.Clear
newSel.Add product1
newSel.PasteSpecial "CATPrtResultWithOutLink"
newSel.Clear
oSel.Clear

Next

RE: PasteSpecial As Result CATVBA not working

check chm file about container and PasteSpecial option.

you can't PasteSpecial "CATPrtResultWithOutLink" or PasteSpecial "CATPrtResult" in a product but in a part only.

Eric N.
indocti discant et ament meminisse periti

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