Need Help on Getting Inertia Value (IozG) in exel File using Catia MACRO

Hi ,
I have created a macro for Extracting details of Assembly. Need help in getting Inertia value of Child parts (IozG) to Ms.Excel file.
Macro is attached. Kindly check it out and provide help for getting Inertia values also in to Excel.

Answer
 
Comments 0

1 Answer

Hi,
I don't understand macros, but I found this:

Inertia:

' COPYRIGHT DASSAULT SYSTEMES 2001
Option Explicit

' ***********************************************************************
' Purpose : Compute the mass and the center of gravity of a component.
' Assumptions : A CATProduct document should be active and a component selected.
' Author :
' Languages : VBScript
' Locales : English
' CATIA Level : V5R6
' ***********************************************************************

Sub CATMain()

' Retrieve the selected component
Dim oSelection As Selection
Set oSelection = CATIA.ActiveDocument.Selection
Dim oProduct As AnyObject
On Error Resume Next
Set oProduct = oSelection.FindObject("CATIAProduct")
If (Err.Number <> 0) Then
MsgBox "No selected product"
Else
On Error Goto 0

' Compute the inertia
Dim oInertia As AnyObject
Set oInertia = oProduct.GetTechnologicalObject("Inertia")

' Read the inertia data
Dim dMass As Double
dMass = oInertia.Mass
Dim dCoordinates(2)
oInertia.GetCOGPosition dCoordinates

' Display the results
MsgBox oProduct.Name & ": Mass = " & Cstr(dMass) & ", Center of gravity : X = " & _
Cstr(dCoordinates(0)) & ", Y = "+Cstr(dCoordinates(1)) & ", Z = "+Cstr(dCoordinates(2))

End If

End Sub

And Excel:

Sub CATMain()


'Creation d'un nouveau workbook Excel
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add

'Dans la première feuille excel, je plannifie les titres de mes collonnes
Set oSheet = oBook.Worksheets(1)
oSheet.Range("A1").value = "t en s"
oSheet.Range("B1").value = "nom_variable_maitre"
oSheet.Range("C1").value =" nom_variable_esclave"
oSheet.Range("A1:C1").Font.Bold = True

For i = 0 To 360 Step 1

Set partDocument1 = CATIA.ActiveDocument

Set part1 = partDocument1.Part

Set parameters1 = part1.Parameters

Set angle1 = parameters1.Item("maitre")

angle1.Value =i

part1.Update

oSheet.Cells(2+i, 2).value = parameters1.Item("maitre").Value
oSheet.Cells(2+i, 3).value = parameters1.Item("esclave").Value

Next

'et c'est fini pour excel
oExcel.Quit

End Sub

COURAGE

 
Comments 0