How to PasteSpecial with a CATIA Macro
|There are different ways that geometry can be pasted “as special” using in CATIA V5.
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
Hello Emmett,
I would like to ask you a question.
I want a simple macro that pastes special with the option “result with link” whatever is in the clipboard. I would then hotkey that macro for ease of use.
How would I do that?
How can you use Microsoaft Script Debugger with CATScript?
Hello,
Can I copy the view from another catia drawing using .read instead of .open in CATIA vba code so that time needed for execution if macro is less.
Any suggestion.
regards…Vijay
Hi Emmett, I’m new in Catia VBA coding. I want to copy one or several bodies from several instances of a part and “paste special with link” them into a different part in a product? How can I do that? Regards,