Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy and Paste Catia V4 Model file into V5

Status
Not open for further replies.

JSVKAN

Mechanical
Dec 20, 2013
20
Hi,
I tried to copy and paste the V4 model file into v5 through VBA coding. I just recorded this procedure and executed it. However, got an error message at the highlighted line in the below coding. Could someone please help me to resolve this issue or Is there any other way to copy and paste V4 model file into v5? Please find the coding below.

Sub CATMain()

Dim document1 As Document
Set document1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = document1.Selection

selection1.Clear

Dim v4MasterModel1 As V4MasterModel
[highlight #FCE94F]Set v4MasterModel1 = document1.GetItem("*MASTER")[/highlight]

selection1.Add v4MasterModel1

selection1.Copy

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As PartDocument
Set partDocument1 = documents1.Add("Part")

Dim product1 As Product
Set product1 = partDocument1.GetItem("Part2")

Dim bSTR1 As String
bSTR1 = product1.DescriptionRef

product1.DescriptionRef = ""

End Sub
 
Replies continue below

Recommended for you

on line "Dim v4MasterModel1 As V4MasterModel"
get rid of the As V4MasterModel

regards,
LWolf
 
Hi LWolf,

Thank you for your reply.

I executed without "As V4Mastermodel" in line "Dim v4MasterModel1 As V4MasterModel". But, I am still getting an error message like "Object doesn't support this action".


 
when I start a new part, I automatically get a hybridbody named "Geometrical Set.1". If that is not a case, you need to create a Geo Set in your code...
Code:
Sub CATMain()

Dim document1 As Document
Set document1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = document1.Selection

selection1.Clear
selection1.Search "Name=*MASTER,all"

selection1.Copy

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As PartDocument
Set partDocument1 = documents1.Add("Part")

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.item("Geometrical Set.1")

selection1.Add hybridBody1

selection1.Paste

End Sub

regards,
LWolf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor