GetCOGPosition not working
GetCOGPosition not working
(OP)
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
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





RE: GetCOGPosition not working
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
RE: GetCOGPosition not working
[...]
Dim cg(2) 'As Double
[...]
Dim ItemInertia 'As Inertia
[...]
it should work
indocti discant et ament meminisse periti
RE: GetCOGPosition not working
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 ?
RE: GetCOGPosition not working
Did you create the EXCEL Object before? Can you post the whole code to see what is not working ?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...