Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetCOGPosition not working

Status
Not open for further replies.

Ruky

Aerospace
Sep 19, 2011
26
CA
Hi,

I dont get this. A pop up error is preventing my code from running. When I debug it points to the line where I use GetCOGPosition for an inertia object I declared and used GetTechnologicalObject on. The Error message goes like this:

Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic


 
Replies continue below

Recommended for you

Hi guys,

So I have the code below. This is my first time trying to get the inertia data from an assembly's parts. Since this is my first time I need someone to tell me where I am doing something wrong or if I am missing a declaration somewhere. Please help.


Sub CATMain()
'!!!!!Purpose of the code is to get the inertia data of each catpart in a given assembly
'!!!!!without using the measure inertia tool and export method.

'-----ASSUMPTIONS USED FOR THE CODE------------------------
'>>>>>The Root Product contains products that are of CATPart type ONLY


'-----DECLARATIONS FOR SET UP------------------------------
Dim Prod_document As ProductDocument
Dim Root_product As Product
Dim Root_children As Products
Dim product_doc As ProductDocument
'------DECLARATIONS FOR LOOPING----------------------------
Dim i As Integer

'------DECLARATIONS FOR INERTIA ANALYSIS PURPOSES----------
Dim ItemToRead As Product
Dim ItemInertia As Inertia
Dim rho As Double
Dim cg(2) As Double


'------SET UP----------------------------------------------

Set Prod_document = CATIA.ActiveDocument
Set Root_product = Prod_document.Product
Set Root_children = Root_product.Products



'-------LOOPING--------------------------------------------

For i = 1 To Root_children.Count
Set ItemToRead = Root_children.Item(i)
Set ItemInertia = ItemToRead.GetTechnologicalObject("Inertia")

ItemInertia.GetCOGPosition cg
'-------Procedure to Write to an Output File
rho = ItemInertia.Density
'-------Procedure to Write to an Output File

Next

End Sub
 
try with the following change:

[...]
Dim cg(2) 'As Double
[...]
Dim ItemInertia 'As Inertia
[...]

it should work




Eric N.
indocti discant et ament meminisse periti
 
Thanks "itsmyjob",

I dont get the error message anymore. But now I have a new problem. When I try to output to excel I do this:

mycell.cells(cell_row,2)=cg(0)
mycell.cells(cell_row,3)=cg(1)
mycell.cells(cell_row,4)=cg(2)


Yet nothing is showing in the excel sheet. Is it because I am calling the cg array values wrong when I output them ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top