Degrees of Freedom - Macro

Degrees of Freedom - Macro

Anonymous
Not applicable
1,206 Views
4 Replies
Message 1 of 5

Degrees of Freedom - Macro

Anonymous
Not applicable

Hello Team,

Greetings!

 

Can anybody help me with a macro / or the method on how to get into the Degrees of Freedom.

I would like take the count of Translation and Rotation counts

 

 

 

Thanks in Advance!

Alex

 

 

0 Likes
Accepted solutions (1)
1,207 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Hi,

 

Yes this is possible:

Public Sub ComponentsWithDegreesOfFreedom()
        Dim oActiveAssDoc As AssemblyDocument
        Set oActiveAssDoc = ThisApplication.ActiveDocument
        
        Dim oTranslationCount As Long
        Dim oTranslationVector As ObjectsEnumerator
        Dim oRotationCount As Long
        Dim oRotationVector As ObjectsEnumerator
        Dim oCenterPoint As Point

        Dim oComponentOccurence As ComponentOccurrence

        For Each oComponentOccurence In oActiveAssDoc.ComponentDefinition.Occurrences
            oComponentOccurence.GetDegreesOfFreedom oTranslationCount, oTranslationVector, oRotationCount, oRotationVector, oCenterPoint
            
            MsgBox oTranslationCount
            MsgBox oTranslationVector.Count
            MsgBox oRotationCount
            MsgBox oRotationVector.Count
            MsgBox oCenterPoint.x
            MsgBox oCenterPoint.Y
            MsgBox oCenterPoint.Z
'Optional ground components If oComponentOccurence.Grounded = False Then oComponentOccurence.Grounded = True End If Next End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 3 of 5

Anonymous
Not applicable

Hi,

Thanks a lot. Now I understand the mistake what I was doing wrong..

 

I was adding the Bracket here all the time, as I am not aware. Smiley Mad

 

    oComponentOccurence.GetDegreesOfFreedom (oTranslationCount, oTranslationVector, oRotationCount, oRotationVector, oCenterPoint)
            
Where my code was always failing at this line. I couldn't understand the method while reading some API and documents related to it.       

 

Basically I am not a programmer, new bee to this VB as well, I am managing a CAD team, and thought of doing some automation, so started in own interest.

 

But it was quite fun doing Automation with Inventor. Smiley LOL

 

Thanks a lot for saving my time

 

 

Regards

Alex

0 Likes
Message 4 of 5

Curtis_Waguespack
Consultant
Consultant

just adding an ilogic version of this that lists the DOF for under constrained components, in case it helps someone else in the future:

 

Dim oActiveAssDoc As AssemblyDocument
oActiveAssDoc = ThisApplication.ActiveDocument

Dim oTranslationCount As Long
Dim oTranslationVector As ObjectsEnumerator
Dim oRotationCount As Long
Dim oRotationVector As ObjectsEnumerator
Dim oCenterPoint As Point
Dim MyArrayList As New ArrayList

Dim oComponentOccurence As ComponentOccurrence

For Each oComponentOccurence In oActiveAssDoc.ComponentDefinition.Occurrences
    oComponentOccurence.GetDegreesOfFreedom _
	(oTranslationCount, oTranslationVector, oRotationCount, oRotationVector, oCenterPoint)
    
	If oTranslationCount > 0 Or oRotationCount > 0 Then
		
		MyArrayList.add(oComponentOccurence.Name _
		& " :   (" & oTranslationCount + oRotationCount & ") degrees of freedom remaining")

	End If

Next

InputListBox("Displaying components with one or more degrees of freedom", _
MyArrayList, "", "ilogic", "Free moving components")

 

EESignature

Message 5 of 5

basile.sciaudeau
Contributor
Contributor

Good afternoon everyone,

 

I'm very interested about this topic but I don't want to count the number of Degree Of Freedom.

My goal is to know which axes or which rotation are degree of freedom.

Is someone can help me ?

 

Thank you in advance.

0 Likes