Sub CatMain() Dim Excel As Object On Error Resume Next 'if Excel is already running, then get the Excel object Set Excel = GetObject(, "Excel.Application") If Err.Number 0 Then 'If Excel is not already running, then create a new session Set Excel = CreateObject("Excel.Application") Excel.Visible = True End If 'add a new workbook 'set the workbook as the active document Set WBK = (1) End Subħ. The first step to exporting any information from inside CATIA is to be able to launch or open Excel. Export to Excel is highly useful as you can create custom bills of material (BOMs) or part lists at the click of a button. Launch Excel from CATIA One of the biggest reasons for learning CATIA macro programming is to be able to automatically export properties from CATIA to an Excel spreadsheet. Sub CATMain() Dim oSelection as Selection Set oSelection = Dim iCount Dim geoName As String geoName = Inputbox("Please enter EXACT name of geometry to search for.") oSelection.Search "Name=" & geoName & "*,all" iCount = oSelection.Count msgbox "Number of shapes found: "&icount For i=1 to iCount CATIA.StartCommand "Center Graph" Next End SubĨ.
Search by Name Do you have an enormous specification tree with thousands of pieces of geometry? Do you need to find one specific element within the tree? Rid yourself hours of endless scrolling by searching for those components directly by name. Sub CATMain() Dim oSel As Selection Set oSel = MsgBox "Number of objects selected: " & oSel.Count Dim i As Integer For i =1 to oSel.Count Dim oSelEl As SelectedElement Set oSelEl = oSel.Item(i) Msgbox " The selected element's name is " & Msgbox "The Selected element's type is " & oSelEl.Typeĩ. For example, you can find out if a plane is HybridShapePlaneExplicit or HybridShapePlaneNormal. The purpose of this program is to help you figure out the syntax for pieces of geometry. What is this? This macro returns the name and type of all objects selected before the program is run.
CATIA V5 MACROS HOW TO
Quick Start Guide to CATIA V5 Macros Never created or ran a macro in CATIA before? Want to learn how to create your own custom CATIA macros? VB Scripting for CATIA V5 is the ultimate quick start guide on how you can begin saving yourself tons of time and complete your projects faster.ġ0. Assign an icon (or create your own) for each macro CATIA macros window keyboard shortcut: Alt+F8ģ. Run Once a CATScript macro is created, there are multiple ways to open the macros window to run the code: 1.
CATIA V5 MACROS CODE
Copy and paste the code into the CATScript editor. Go to Tools>Macro>Macros (or hit Alt+F8) to open the macro window. How to Run Macros in CATIA V5 To run the macros: 1.
CATIA V5 MACROS FREE
Feel free to use these in any way that will benefit you. You can increase your programming speed by reusing snippets of code you’ve already written that you know work. While each piece of code by itself may not be the final solution to your problem, they can quickly and easily be placed into larger, more complicated programs.
Top Ten CATIA V5 CATScript Macros Emmett Ross The following programs are the snippets of code I find myself using more than any others.