×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

GetCOGPosition not working

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


RE: GetCOGPosition not working

(OP)
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

RE: GetCOGPosition not working

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

RE: GetCOGPosition not working

(OP)
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 ?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources