CATIA macro publication + free macro download
Introduction
Publications in CATIA are one of the most important things. It helps you to connect your model. You can’t work on serious models without publications. So if you don’t use it, please stop here and watch this video first Publication example. That was from a modeling perspective, from a macro perspective it’s also important. If you want to make advanced macros you must integrate publications in the code.
Free CATIA macro publication
Publications are very important for complex models. Hence we want to show you simple CATIA macro for them. The publication part is very important. First of all when you make complex macros. So it’s very important to know how to make it. Also, you can read more about problems with CATIA publication on this forum post. We took just one code from this post. Because of similarity with this CATIA macro publication.
Add-on for VB code is making an error it converts “&” to “&”
Public Sub CreatePublications(ByVal pubProduct As Product, _ ByVal pubCollection As Collection) Dim pubRef As Reference Dim thePublications As Publications Dim thePublication As Publication Dim i As Integer Dim pubObject As Object For i = 1 To pubCollection.Count Set pubObject = pubCollection.Item(i) Set pubRef = pubProduct.CreateReferenceFromName(pubProduct.Name & "/!" & pubObject.Name) Set thePublications = pubProduct.Publications Set thePublication = thePublications.Add(pubObject.Name) thePublications.SetDirect pubObject.Name, pubRef pubProduct.Update Next i End Sub
This free CATIA macro has two buttons and one list of items. So if you want a similar app or code you will need also multiple selections. You use it when you select bodies. So then that goes to the list. Even more, when you run the macro it will publish any element from this list. In this case, it’s more like two separated macros connected with this list. So we just use options inside VB. For CATScript you must use one macro. Also, you must use array to make this happen.
Dim strArray(0) strArray(0) = "AnyObject" Dim sStatus As String sStatus = oSel.SelectElement3(strArray, "Select Elements for name change", False, CATMultiSelectionMode.CATMultiSelTriggWhenUserValidatesSelection, False)
This is code for multiple selection pallet.
If you are not familiar with CATIA publication you can see this video.