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!

CATIA v6 2013x(VBA) Add New Product file and add an existing part in it.

Status
Not open for further replies.

Maddy02

Mechanical
Feb 14, 2013
114
Hi,

i'm new to v6 automation and have worked in v5 automation.

Can any one help/post some sample reference code to create new product in V62013x and then add an existing 3D part in to the newly created product.

i was able to create a new product and fetch the existing (opened part), but could not able to load the existing part into the new product's root collection.

here is my code:

Code:
    Dim oPart As Part
    Dim oPartVPMRepRef As VPMRepReference
    Dim oPartVPMRef As VPMReference
    Dim oProdVPMRef As VPMReference
    Dim oProdRootReference As VPMReference
    Dim oProdRootOccurrence As Object

    Set oPart = CATIA.ActiveEditor.ActiveObject
    Set oPartVPMRepRef = oPart.Parent
    Set oPartVPMRef = oPartVPMRepRef.Father
    
    Call CATIA.GetSessionService("PLMNewService").PLMCreate("Product", oProductEditor )
 
    Set oProdRootReference = oProductEditor.GetService("PLMProductService").RootOccurrence.ReferenceRootOccurrenceOf
    

    'Tried this 
    Dim oVPMRepInstsOnRepInstColln As VPMRepInstances
    Dim oNewProdRepInst As VPMRepInstance
    Dim cListRepInstancesColln As VPMRepInstances
    Dim sRepInstanceName As String
    Set cListRepInstancesColln = oProdRootReference.RepInstances
    sRepInstanceName = "I_" & oProdRepRefToInstantiate.Name & "." & cListRepInstancesColln.Count + 1
    Set cListRepInstancesColln =cListRepInstancesColln.Add(sRepInstanceName, oProdRepRefToInstantiate.Parent, oNewProdRepInst)  ' -- Not Works
    ' Error : Add Method of VPMRepInstances Failed

    ' And also This 
    Dim oVPMInstancesOnInstColln As VPMInstances
    Dim oNewProdInstance As VPMInstance
    Set oVPMInstancesOnInstColln = oProdRootReference.Instances
    Call oVPMInstancesOnInstColln.Add(oPartVPMRef, oNewProdInstance) ' -- Not Works
    ' Error : Add Method of VPMInstances Failed


Please let me know how to proceed.


Regards,
Maddy

 
Replies continue below

Recommended for you

yes, Ferdo,

Scenario is like this (CATIA V62013x)
I need to create an assembly from opened 3DParts and i have 2 part files opened
1. Part1​
2. Part2​

I created a new product Product1 (Assembly - through program)

Now i need to add Part1 and Part2 to Product1 (New Product)

And then put a constraint (contact constraint) between Part1 and Part2

Hope it is clear now.

i'm facing error while instantiating Part1 (VPMReference) onto Product1's Root Reference

i followed the way API described (oProdRootReference.RepInstances.Add and oProdRootReference.Instances.Add) but not works.

Don't know where doing i'm wrong

Regards,
Maddy

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor