CATIA V6 Macro - Insert new 3DPart under Product
CATIA V6 Macro - Insert new 3DPart under Product
(OP)
Hi
I want to write a macro using VB.NET or VBA to insert a new 3DPart or 3DShape under a product. I read V6 Automation Help document but i don't see it. I also used record but CATIA can't record that action. I followed this example to write my code Instantiating Product Representation Reference but it doesn't work. Here is my code:
When i debug, cListInstances error: nothing
What can I do to fix that?
Thanks
I want to write a macro using VB.NET or VBA to insert a new 3DPart or 3DShape under a product. I read V6 Automation Help document but i don't see it. I also used record but CATIA can't record that action. I followed this example to write my code Instantiating Product Representation Reference but it doesn't work. Here is my code:
CODE --> VB.NET
Public Sub Macro_Chenbulong()
Dim ActiveEditor As Editor
ActiveEditor = CATIA.ActiveEditor
Dim oProductService As PLMProductService
oProductService = ActiveEditor.GetService("PLMProductService")
Dim oVPMRootOccOnRoot As VPMRootOccurrence
oVPMRootOccOnRoot = oProductService.RootOccurrence
Dim oVPMRefOnRoot As VPMReference
oVPMRefOnRoot = oVPMRootOccOnRoot.ReferenceRootOccurrenceOf
CATIA.GetSessionService("PLMPropagateService").Save()
Dim My3DPartService As PLMNewService
My3DPartService = CATIA.GetSessionService("PLMNewService")
Dim MyEditor3DShape As Editor
My3DPartService.PLMCreate("3DPart", MyEditor3DShape)
Dim MyEditor As Part
MyEditor = MyEditor3DShape.ActiveObject
Dim MyVPMRepRef As VPMRepReference
MyVPMRepRef = MyEditor.Parent
Dim MyRootRef As VPMReference
MyRootRef = MyVPMRepRef.Father
Dim cListInstances As VPMInstances
cListInstances = oVPMRefOnRoot.Instances
Dim oNewProdInst As VPMInstance
cListInstances.Add(MyRootRef, oNewProdInst)
End Sub When i debug, cListInstances error: nothing
What can I do to fix that?
Thanks





RE: CATIA V6 Macro - Insert new 3DPart under Product
I might be wrong but what the hell: are you trying to add a VPMRepInstance (the instance of 3DPart) of a VPMRepReference (the actual 3DPart) in a collection of VPMInstances? Isn't that wrong? I imagine you should call the VPMRepInstances collection instead of VPMInstances.
Hope it helps,
Calin
RE: CATIA V6 Macro - Insert new 3DPart under Product
Sub Add( VPMReference iProductReference,
VPMInstance oProductInstance)
Creates a new child PLM Product Instance.
This example shows you how to instantiate a PLM Product Reference (oProdRefToBeInstantiated), to insert the new instance below another given PLM Product Reference (oProdRefAsParent)
CODE --> VB.NET
RE: CATIA V6 Macro - Insert new 3DPart under Product