×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

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!
  • Students Click Here

*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

Jobs

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

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

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

(OP)
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

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

(OP)
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

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!


Resources