How to PasteSpecial with a CATIA Macro

There are different ways that geometry can be pasted “as special” using in CATIA V5.

pasting with vba macro

Depending on the type of object you are pasting, you can choose between the following formats:

  • As specified in Part document: the object is copied as it has been created but generally without its design specifications. For instance, surface features cannot be copied with their design specifications whereas pads can.
  • As Result With Link: the object is copied without its design specifications and is linked to the original object. In other words, whenever the original object is modified, the copied object may be manually updated to reflect the changes.
  • As Result: the object is copied without its design specifications and without any link with the original object. It is considered as an autonomous entity. When using this option, solids and curves are created. However, note that regarding ordered geometrical sets, hybrid bodies and part bodies, only the final result is copied.
  • As Specified in Product Structure: the source instance is duplicated and the link to the source reference is kept. A new instance of the source is created and it has the same reference as the source.
  • As Specified in Assembly
  • As Result With Link Flat Mode to paste a flattened object.
  • As Result all views: the sheetmetal object is copied as a solid with both folded and unfolded views (sheet metal design)
  • As Result With Link all views: the sheetmetal object is copied as a solid with both folded and unfolded views and with a link to the original object. This means that whenever the original object is modified, the solid is updated accordingly.

So how do you use Paste Special options with regards to CATIA macros? Use the syntax below:

  • “CATPrtCont” to paste “As Specified In Part Document”
  • “CATPrtResultWithOutLink” to paste “AsResult”
  • “CATPrtResult” to paste “AsResultWithLink”
  • “CATMaterialCont” to paste “As material”
  • “AsMaterialLink” to paste “As material link”
  • “CATMechProdCont” to paste “As specified in Assembly”
  • “CATProdCont” to paste “As specified in Product Structure”
  • “CATIA_SPEC” to paste “CATIA_SPEC”
  • “CATIA_RESULT” to paste “CATIA_RESULT”

PasteSpecial Example

Here is an example how you might copied a selected object and paste it into a newly created 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 = “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.paste

‘newSel.PasteSpecial “CATPRTResultwithoutlink”

‘newSel.PasteSpecial “CATPrtResult”

newSel.PasteSpecial “CATProdCont”

newSel.Clear

oSel.Clear

Add a Comment

Your email address will not be published. Required fields are marked *