Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to drive constraints

martinhoos
Advocate

How to drive constraints

martinhoos
Advocate
Advocate

Hello together,

i need your your help. I like to drive, move and rotate constraints with ilogic. The following code rotates all of the driven constraints. The code shouldt be drive only a constraint named "move1" vertical from 0 to 155 and rotated an other constraint named "rotate1" from 0 to 45 degree. Is that possible?

 

And another question: The code rotates clockwise from 0 to 45 degree. Is it possible to rotate from 0 to -45?

 

Thanks in advance

Regards Martin

 

Sub Main()
    Dim assyDoc As AssemblyDocument
    assyDoc = ThisApplication.ActiveDocument
    Dim oConstraint As AssemblyConstraint
    For Each oConstraint In assyDoc.ComponentDefinition.Constraints
        If oConstraint.DriveConstraintSettings.IsInitialized Then
            With oConstraint.DriveConstraintSettings

				.StartValue = 0
                .EndValue = 45
                .GoToStart               
                .PlayForward
'                .StartValue = 0
'                .EndValue = 150
'                .GoToEnd
'                .PlayReverse

			End With
        End If
    Next
End Sub
0 Likes
Reply
Accepted solutions (2)
1,237 Views
3 Replies
Replies (3)

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@martinhoos,

 

Try below iLogic code to move and rotate to drive constraints.

 

Sub Main()
    Dim assyDoc As AssemblyDocument
    assyDoc = ThisApplication.ActiveDocument
    Dim oConstraint As AssemblyConstraint
    For Each oConstraint In assyDoc.ComponentDefinition.Constraints
		If oConstraint.Name = "move1" Then
			If oConstraint.DriveConstraintSettings.IsInitialized Then
	            With oConstraint.DriveConstraintSettings
			.StartValue = "0"
	                .EndValue = "155"
	                .GoToStart               
	                .PlayForward 

				End With
        	End If
		ElseIf oConstraint.Name = "rotate1" Then
			If oConstraint.DriveConstraintSettings.IsInitialized Then
	            With oConstraint.DriveConstraintSettings
			.StartValue = 0
	                .EndValue = 45
	                .GoToStart               
	                .PlayForward 

				End With
        	End If
		End If 
		
        
    Next
End Sub

Is it possible to rotate from 0 to -45?

Try 0 to 315 (360 - 45) to rotate from 0 to -45.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



martinhoos
Advocate
Advocate
Accepted solution

Hello Chandra,

thank you very much for your help! Great work...

Regards Martin

0 Likes

miroslav.roydev
Enthusiast
Enthusiast

How i can drive multiple constraints ?

0 Likes