I'm working on a project and I've been making headway and have ran into a problem in which I need help. I am attempting to publish user defined properties for parts at various levels. I am able to target the area but every time I attempt to create a reference it fails. Also, CATIA says that these elements are not publishable. I am able to publish when a part is in top level, what changes?
Below is my code that targets and should make the publications.
Sub Sublevel_Part_Publication()
'This is a work in progress sub
For i = 1 To CATIA.Documents.Count
'MsgBox i
If CATIA.Documents.Item(i).Name = CATIA.ActiveDocument.Selection.Item(1).LeafProduct.ReferenceProduct.Name & ".CATPart" Then
Set Active_Name_Input = CATIA.Documents.Item(i).GetItem(1)
End If
Next
Dim product1
Set product1 = Active_Name_Input
Dim PARAMS As Parameters
Set PARAMS = product1.Parameters
Dim RELATIONS As RELATIONS
Set RELATIONS = product1.RELATIONS
Dim PUBS As Publications
Set PUBS = product1.Publications
Set PARAM_MANUF = PARAMS.CreateString("MANUFACTURER/SOURCE", "")
'----- CREATE RELATIONS (FORMULAS) -----
Set FORMULA_MANUF = RELATIONS.CreateFormula("MANUF", "", PARAM_MANUF, "`Properties\MANUFACTURER/SOURCE` ") '"`" & Active_Name_Input.Name & "\Properties\MANUFACTURER/SOURCE` "
'----- CREATE PUBLICATIONS -----
Set REF_MANUF = product1.CreateReferenceFromName("MANUFACTURER/SOURCE")
Set PUB_MANUF = PUBS.Add("MANUFACTURER/SOURCE")
PUBS.SetDirect "MANUFACTURER/SOURCE", REF_MANUF
End Sub
I attempted to do the direct route for publications and that continuously failed. Doing the parameters and formulas is a work around that works.
I figured it out by breaking down the code to a different levels. It appears that settings relations and publications are on a different level than parameters.
For i = 1 To CATIA_Input.Count
'MsgBox i
If CATIA.Documents.Item(i).Name = CATIA.ActiveDocument.Selection.Item(1).LeafProduct.ReferenceProduct.Name & ".CATPart" Then
Set Active_Name_Input = CATIA.Documents.Item(i)
End If
Next
Dim product1
Set product1 = Active_Name_Input.GetItem(1)
Dim part1
Set part1 = Active_Name_Input.part