I'm trying to make a Publication of points, line and planes in a geometrical set of Part using a VBA script.
I get an error on of the SetDirect method of publications1, where the error says "The method SetDirect failed".
The Publication is added to the list, but the Element is empty.
I've tried
publications1.SetDirect("centerPoint1", reference1)
and publications1.SetDirect "centerPoint1", reference1
.
Here's the documentation; http://catiadoc.free.fr/online/interfaces/interface_Publications.htm
What am I doing wrong? I think it could be the making of reference1? Is it possible to make Publications using a VBA script?
Image of the part where I want to make the Publication
The VBA Code
Sub publicationTest2()
Set CATIA = GetObject(, "CATIA.Application")
Set documents1 = CATIA.Documents
Set partDocument1 = documents1.Item("Part1.CATPart")
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("arr_set")
Set hybridShapes1 = hybridBody1.HybridShapes
Set hybridShapePointOnPlane1 = hybridShapes1.Item("centerPoint1")
'Set publications1 = CATIA.ActiveDocument.Product.Products.Item(partName).Publications
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products
Set product2 = products1.Item("Part1.1")
Set publications1 = product2.Publications
Set reference1 = hybridShapePointOnPlane1
publications1.Remove ("centerPoint1")
Set publication1 = publications1.Add("centerPoint1")
part1.Update
Set publ1 = publications1.SetDirect("centerPoint1", reference1)
End Sub