×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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

Catia macro PasteAsResult

Catia macro PasteAsResult

Catia macro PasteAsResult

(OP)
Hi all. Is it possible to use a macro to copy the entire contents of an open active Product and, using a special paste, paste it into a new Part or Product as a result and ONE body/Solid?

I tried to run the following code in two versions:

CODE --> vb.net

Dim activeDocument As ProductDocument = Catia.ActiveDocument

        Dim rootProduct As Product = activeDocument.Product
       
        Catia.ActiveWindow.ActiveViewer.Reframe()
        Catia.ActiveDocument.Selection.Search("Name=*,all")
      
        Catia.ActiveDocument.Selection.Copy()
      
        Dim newProductDocument As ProductStructureTypeLib.ProductDocument = Catia.Documents.Add("Product")
 
        newProductDocument.Selection.PasteSpecial("CATPrtResultWithOutLink") 





CODE --> vb.net

Dim productDocument As ProductStructureTypeLib.ProductDocument = Catia.ActiveDocument

       
        Dim product As ProductStructureTypeLib.Product = productDocument.Product

        
        Dim selection As INFITF.Selection = Catia.ActiveDocument.Selection

        
        selection.Clear()

      
        For Each product In product.Products
            selection.Add(product)
        Next

      
        selection.Copy()
       
    
        Dim partDocument As PartDocument = Catia.Documents.Add("Part")

       partDocument.Selection.PasteSpecial("CATPrtResultWithOutLink") 





but I get the same error:

CODE -->

System.Runtime.InteropServices.COMException
  HResult=0x80004005
  Message=Empty CSO element. Operation cannot be performed PasteSpecial. 

RE: Catia macro PasteAsResult

Create AllCatPart...

regards,
LWolf

RE: Catia macro PasteAsResult

(OP)
When I form an allcatpart, it leaves the same amount of tree products

RE: Catia macro PasteAsResult

in CATAllPart you get the option to create only one body for each part/solid: "Merge all bodies of each part in one body" option

regards,
LWolf

RE: Catia macro PasteAsResult

(OP)
Yes, I use this checkbox. But the result remains the same. And if I'm use allcatpart code generation, then nothing changes either

RE: Catia macro PasteAsResult

Make an allcatpart, then assembly all bodies in main body , copy this catpart in a product and make again an allcatpart.

RE: Catia macro PasteAsResult

TudorM has the solution. I have fully automated this process in the past but it requires using un-managed code to click the 'OK' button on the CATAllPart dialog, after calling CATIA.StartCommand, since there is no API for running that function (try searching pinvoke for details on this). Once that has been completed you can handle the new part that is has created, combining all of the bodies into one and then copy/paste as result that body to make a single solid. The code I originally wrote replaced the staring sub-product as well.

RE: Catia macro PasteAsResult

weagan22, there is a method for CATAllpart, WITHOUT running StartCommand...

regards,
LWolf

RE: Catia macro PasteAsResult

Quote (TudorM)

Make an allcatpart, then assembly all bodies in main body , copy this catpart in a product and make again an allcatpart.

Catia has some cheesy workarounds and solutions but at least it has them. (unlike all my previous cad systems)

RE: Catia macro PasteAsResult

Wuzhee: Definitely cheesy workarounds, but it always does seem to work, somehow.

LWolf, is there an API command that runs 'Generate CATPart from Product'? I have never seen/heard of this in any of the documentation, but I also haven't worked on any new releases beyond R28. If so, what library is it in, out of curiosity? Or are you just taking about manually coding the combine by copying part bodies out of each of the sub-components without running that command at all?

RE: Catia macro PasteAsResult

weagan22, it is literally in elmundos777 previous thread:
thread560-513775: Generate AllCatPart from Product (Vb.net): Generate AllCatPart from Product (Vb.net)" target="_blank" rel="nofollow">Link

Dim oBGRoot, oBGProd, sError
Dim oProd2Part As DECPartToPart
Dim oAllCatPart As part
Set oBGRoot = CATIA.ActiveDocument
Set oBGProd = oBGRoot.Product
Set oProd2Part = oBGProd.GetItem("DECPartToPart")
oProd2Part.Run
sError = oProd2Part.GetError
If sError <> "" Then
MsgBox sError, 16, "Exception DECPartToPart. Aborting."
Exit Sub
End If
Set oAllCatPart = oProd2Part.GetResult.part
actually this thread is kind of a duplicate... to that thread

regards,
LWolf

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! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close