Transfrom2 help for GetAllComponentMassprop API

Discussion in 'SolidWorks' started by Triton, Jan 27, 2005.

  1. Triton

    Triton Guest

    I'm modifying Stefan Berlitz's code (mm_02.zip found at
    http://swtools.cad.de/macros.htm) to pull mass properties out of an
    assembly and list them into an excel spreadsheet. What I'm
    specifically trying to do is pull out the centres of gravity for all
    parts in an assembly with reference to the assembly's origin, and list
    them in the spreadsheet.

    After simply modification of Stefan's code, I am getting x,y, and z
    coordinates of parts relative to their own origin. Now i'd like to
    transform these so that they are relative to the assembly's origin. I
    believe I need to use Component2::Transform2, but I'm not sure how to
    implement this. I do not claim to be able to program, but simple
    changes to code I can do!

    Can anyone point me in the right direction?

    Thanks!
    Scott

    Here's an bit of code that shows how the x coordinate of the cg of a
    part is being obtained:

    Range("F" & zeile).Select
    If Component.IsSuppressed Then
    ActiveCell.FormulaR1C1 = "*** Component is Suppressed ***"
    Else
    ' dann das ModelDoc der Komponente herausholen
    ConfigName = Component.ReferencedConfiguration
    Set ModelDoc = Component.GetModelDoc()
    If Not ModelDoc Is Nothing Then
    ' und die MassProperties auslesen
    ModelDoc.ShowConfiguration (ConfigName)
    MassProp = ModelDoc.GetMassProperties()
    ' die Reihenfolge der MassProps im Variant ist:
    ' CenterOfMassX, CenterOfMassY, CenterOfMassZ, Volume,
    Area, Mass,
    ' MomXX, MomYY, MomZZ, MomXY, MomZX, MomYZ
    ' Masse ist die 6. Eigenschaft, also Index 5
    ' 39.3700787402 WAS ADDED BY SCOTT TO CONVERT DEFAULT
    POSITION FROM M TO IN
    ActiveCell.FormulaR1C1 = MassProp(1) * 39.3700787402
    Else
    ActiveCell.FormulaR1C1 = "*** Kein ModelDoc,
    Rootkomponente? ***"
    End If
    End If
     
    Triton, Jan 27, 2005
    #1
  2. Triton

    CS Guest

    Look up the math transform utility.
     
    CS, Jan 27, 2005
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.