Search code examples
excelvbacatia

How to change render style in CATIA V5 through Excel VBA?


I wrote a macro that saves an image from CATIA, using the CaptureToFile method in the Viewer object. The macro works great, but only when the Render Style is "Parallel". Some of the designers in my company do not have the Render Style to "Parallel", so I want to change the Render Style to "Parallel" with the macro.

There is a property in the TreeTabSettingAtt object, called RenderStyle. The documentation says that the property "Returns or sets the value to signify whether the 3D Render Style is Parallel or Perspective". It seems to be exactly what I need. To get to that property, I need to get to the TreeTabSettingAtt object, which seems to be a SettingController in the SettingControllers collection, but I can't get to it because I don't know its object type. The latter is needed to be passed as an argument of the Item method of the setting controller collection object. Unfortunately, the Item method only takes a string, which I don't know.

sub CATMain()

    Dim catia as INFITF.Application
    Dim att as PROCESSITF.TreeTabSettingAtt

    Set catia = GetObject(, "catia.Application")

    Set att = catia.SettingControllers.Item("I dont know the object type of 
    TreeTabSettingAtt")

    att.RenderStyle "Parallel"

End Sub

In the documentation, seen in the following link, the setting controller object type of many setting controller objects are listed, but some are missing including the object type for the TreeTabSettingAtt setting controller object. https://www.maruf.ca/files/caadoc/CAAScdInfTechArticles/CAAInfTabPageList.htm


Solution

  • The property you've located seems bound to the application settings (i.e. the ones you change from Tools>Options..). I don't know how good they are exposed to automation but from a quick debug session, it was evident that with

    Set att = CATIA.SettingControllers
    

    one actually gets the collection, Count property is 70 in my case, but no Item method was available! This is inconsistent with the documentation. Note that the documentation reports that the argument must be an index in long format, but passed as a string.

    Answer:

    I have instead located the "live setting" which is bound to the Viewpoint3D object as follows. Note that either in CATScript or CATVBA you don't need to assign the Application object (CATIA object of class Application is always available):

    Set view = CATIA.ActiveWindow.ActiveViewer.Viewpoint3D
    view.ProjectionMode = catProjectionCylindric
    'or
    view.ProjectionMode = catProjectionConic