<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									CatiaWidgets Forum - Recent Posts				            </title>
            <link>https://www.catiawidgets.net/catiawidgetsforum/</link>
            <description>CatiaWidgets Discussion Board</description>
            <language>en-GB</language>
            <lastBuildDate>Sat, 18 Apr 2026 10:26:52 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Create Publication via Macro</title>
                        <link>https://www.catiawidgets.net/catiawidgetsforum/v6/create-publication-via-macro/#post-194</link>
                        <pubDate>Tue, 23 Dec 2025 11:20:28 +0000</pubDate>
                        <description><![CDATA[HelloTrying desesperatly to CREATE A publication in MAcro Language VBA with the following codeCould someone help me pleaseSub CATMain()Dim EngCntEditor As Object: Set EngCntEditor = CATIA.Ac...]]></description>
                        <content:encoded><![CDATA[<p><strong>Hello<br /></strong>Trying desesperatly to CREATE A publication in MAcro Language VBA with the following code<br />Could someone help me please<br /><br /><br />Sub CATMain()<br />Dim EngCntEditor As Object: Set EngCntEditor = CATIA.ActiveEditor<br /><br />' 1. Accès au service de publication (plus puissant que l'accès par l'objet)<br />Dim simPubService As Object<br />On Error Resume Next<br />Set simPubService = EngCntEditor.GetService("SimPublicationServices")<br />On Error GoTo 0<br /><br />If simPubService Is Nothing Then<br />MsgBox "Le service de publication est indisponible. Vérifiez vos licences."<br />Exit Sub<br />End If<br /><br />' 2. Récupérer l'assemblage racine<br />Dim myProdService As PLMProductService: Set myProdService = EngCntEditor.GetService("PLMProductService")<br />Dim myRootOcc As VPMRootOccurrence: Set myRootOcc = myProdService.RootOccurrence<br />Dim myRootRef As VPMReference: Set myRootRef = myRootOcc.ReferenceRootOccurrenceOf<br /><br /><br />Dim ioCATIA As Application<br />Set ioCATIA = CATIA<br /><br />'Get The Active Object i.e. Root object<br />Dim ioVPMRootOccurence As VPMRootOccurrence<br />Set ioVPMRootOccurence = ioCATIA.ActiveEditor.ActiveObject<br /><br />' Get the Child Occurences i.e. the objects below the root<br />Dim ioVPMOccurences As VPMOccurrences<br />Set ioVPMOccurences = ioVPMRootOccurence.Occurrences<br /><br />' Get the first Child Occurence<br />Dim ioOccurence As VPMOccurrence<br />Set ioOccurence = ioVPMOccurences.Item(1)<br /><br />' Get the VPM Instance from the Child Occurence<br />Dim ioVPMInstance As VPMInstance<br />Set ioVPMInstance = ioOccurence.InstanceOccurrenceOf<br /><br />' Get the VPM Reference from the VPM Instance<br />Dim ioVPMReference As VPMReference<br />Set ioVPMReference = ioVPMInstance.ReferenceInstanceOf<br /><br />' Get the VPM Representation Instances<br />Dim ioVPMRepInstances As VPMRepInstances<br />Set ioVPMRepInstances = ioVPMReference.repInstances<br /><br />' A 3D Part may have multiple reps below it i.e. a Shape and a Drawing<br />' Get the first Representation Instance from the VPM Representation Instances<br />Dim ioVPMRepInstance As VPMRepInstance<br />Set ioVPMRepInstance = ioVPMRepInstances.Item(1)<br /><br />' Get the VPM Representation Reference from the Representation Instance<br />Dim ioVPMRepReference As VPMRepReference<br />Set ioVPMRepReference = ioVPMRepInstance.ReferenceInstanceOf<br /><br />' Get the Part from the VPM Representation Reference<br />Dim ioPart As Part<br />Set ioPart = ioVPMRepReference.GetItem("Part")<br /><br />MsgBox ioPart.axisSystems.Item(2).name<br /><br /><br />' ' 3. Récupérer l'élément sélectionné<br />' Dim mySelection As Object: Set mySelection = EngCntEditor.Selection<br />' If mySelection.Count = 0 Then<br />' MsgBox "Sélectionnez l'axe 'RepTgt' dans l'arbre."<br />' Exit Sub<br />' End If<br /><br /><br /><br />'mySelection.VisProperties.SetRealColor 255, 255, 0, 1 ' Repère en jaune<br /><br /><br /><br /><br />' 4. RÉCUPÉRATION DU LIEN CONTEXTUEL<br />Dim oAxis As Object: Set oAxis = ioPart.axisSystems.Item(2)<br /><br /><br />' On tente de créer une référence contextuelle<br />Dim myRef As Object<br />On Error Resume Next<br />' Set myRef = ioOccurence.CreateReferenceFromObject(oAxis) ' CREATE AN EMPTY PUBLICATION<br />Set myRef = ioPart.axisSystems.Item(1) 'DOESN'T CREATE ANY PUBLICATION<br />On Error GoTo 0<br /><br /><br /><br />' 5. CRÉATION PAR LE SERVICE (Sans passer par la collection)<br />Dim pubName As String: pubName = "PubliRep"<br />Dim newPublication As Object<br /><br />On Error Resume Next<br />' C'est la fonction la plus robuste de l'API 3DEXPERIENCE<br />Set newPublication = simPubService.CreatePublication(myRootRef, myRef, pubName)<br />On Error GoTo 0<br /><br />' 6. VERIFICATION<br />If Not newPublication Is Nothing Then<br />MsgBox "SUCCÈS ! Publication créée via SimPublicationServices."<br />' Rafraîchissement forcé<br /><br />Else<br />MsgBox "Même le service de simulation a échoué." &amp; vbCrLf &amp; _<br />"Vérifiez si l'objet racine (" &amp; myRootRef.GetIdentifier &amp; ") n'est pas verrouillé par un autre utilisateur."<br />End If<br /><br />MsgBox newPublication.name<br /><br />End Sub<br /><br /><br /><br /></p>]]></content:encoded>
						                            <category domain="https://www.catiawidgets.net/catiawidgetsforum/"></category>                        <dc:creator>Denis Douillet</dc:creator>
                        <guid isPermaLink="true">https://www.catiawidgets.net/catiawidgetsforum/v6/create-publication-via-macro/#post-194</guid>
                    </item>
							        </channel>
        </rss>
		