Phuc Phan Tu
Structural
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:
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