How to ... Second Moment Area ..iProperties?

How to ... Second Moment Area ..iProperties?

Anonymous
Not applicable
1,028 Views
1 Reply
Message 1 of 2

How to ... Second Moment Area ..iProperties?

Anonymous
Not applicable

From an extruded part

Inspect tab

Section

Advanced properties

Calculate

 

This will return the second moment of area for an extrustion.

 

How can these values be added to a custom iproperty using iLogic?

 

Rgds

 

MES

0 Likes
1,029 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Oh Code!

---------

 

Taking sample code supplied in the Programming Help " Get region properties from a sketch profile" & pasting into ilogic creates a nice error list which c...

 

Error in rule: Rule0, in document: xxyy.ipt

Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.Sketch'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{5FDB5E25-C96F-11D5-8DF9-0010B541CAA8}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

-------

 

The code is:

 

 

'Public Sub GetProfileRegionProperties()
    ' Set a reference to the active sketch.
    ' This assumes a 2D sketch is active.
    Dim oSketch As Sketch
    oSketch = ThisApplication.ActiveEditObject
    
    ' Create a default profile from the sketch.
    Dim oProfile As Profile
    oProfile = oSketch.Profiles.AddForSolid
    
    ' Set a reference to the region properties object.
    Dim oRegionProps As RegionProperties
    oRegionProps = oProfile.RegionProperties

    ' Set the accuracy to medium.
    oRegionProps.Accuracy = kMedium

    ' Display the region properties of the profile.
    Debug.Print ("Area: " & oRegionProps.Area)
    
    Debug.Print ("Perimeter: " & oRegionProps.Perimeter)
    
    Debug.Print ("Centroid: " & _
                    oRegionProps.Centroid.X & ", " & _
                    oRegionProps.Centroid.Y)

    Dim adPrincipalMoments(1) As Double
	ReDim adPrincipalMoments(2)
	ReDim adPrincipalMoments(3)
	
    Call oRegionProps.PrincipalMomentsOfInertia(adPrincipalMoments(1), _
                                                    adPrincipalMoments(2), _
                                                    adPrincipalMoments(3))
    Debug.Print ("Principal Moments of Inertia: " & _
                    adPrincipalMoments(1) & ", " & _
                    adPrincipalMoments(2))

    Dim adRadiusOfGyration(1) As Double
		ReDim adRadiusOfGyration(2)
	ReDim adRadiusOfGyration(3)
	
    Call oRegionProps.RadiusOfGyration(adRadiusOfGyration(1), _
                                            adRadiusOfGyration(2), _
                                            adRadiusOfGyration(3))
    Debug.Print ("Radius of Gyration: " & _
                    adRadiusOfGyration(1) & ", " & _
                    adRadiusOfGyration(2))

    Dim Ixx As Double
    Dim Iyy As Double
    Dim Izz As Double
    Dim Ixy As Double
    Dim Iyz As Double
    Dim Ixz As Double
    Call oRegionProps.MomentsOfInertia(Ixx, Iyy, Izz, Ixy, Iyz, Ixz)
    Debug.Print ("Moments: ")
    Debug.Print (" Ixx: " & Ixx)
    Debug.Print (" Iyy: " & Iyy)
    Debug.Print (" Ixy: " & Ixy)
    
    Debug.Print ("Rotation Angle from projected Sketch Origin to Principle Axes: " _
    & oRegionProps.RotationAngle)
'    
'End Sub
'

 What does:

"Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.Sketch"

mean?

 

Cheers

 

MES

0 Likes