×
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

Finding Center of Gravity of a selected Surface

Finding Center of Gravity of a selected Surface

Finding Center of Gravity of a selected Surface

(OP)
How to get the center of gravity coordinates for the selected surface. What function can be used for it ?

I tried with the below code. but its not giving correct values..i selected a surface with dimention 8x2 rectangle. and the below code gives the values as 10, 0 , 5.08

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory

Set objNetwork = CreateObject("Wscript.Network")
Set hb1=CATIA.ActiveDocument.Part.InWorkObject
Set hsf=CATIA.ActiveDocument.Part.HybridShapeFactory
Set prt=CATIA.ActiveDocument.Part
Set sel=CATIA.ActiveDocument.Selection
Set SPAWorkBench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Set planeZX = CATIA.ActiveDocument.Part.OriginElements.PlaneZX

Dim inpt1(0)
Dim inpt2(0)
Dim inpt3(0)
inpt1(0) = "Face"
inpt2(0) = "Plane"
inpt3(0) = "Point"

MsgBox "Select a Surface"
Status = Sel.SelectElement2(inpt1, "Select a Surface", False)
Dim selectedElement1
'Set selectedElement1 = Sel.Item(1)
Set selectedElement1 = Sel.Item(1).Value
Dim m
m = selectedElement1.Name
MsgBox m


Dim reference1
Set reference1 = Part1.CreateReferenceFromName(m)

Dim CurrWorkbench
Set CurrWorkbench = partDocument1.GetWorkbench("SPAWorkbench")

Dim Measure
Set Measure = CurrWorkbench.GetMeasurable(reference1)

Dim originCoord(2)

Measure.GetCOG originCoord

MsgBox (originCoord(0)) & " " & (originCoord(1)) & " " & (originCoord(2))

End Sub

Can someone tell me hat went wrong in the above code

Thanks & Regards
Barath

RE: Finding Center of Gravity of a selected Surface

Have you tried simply using Measure Item or Measure Intertia?

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