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

How do delete the Angle Constraint of Selected Components in Assembly ILogic

Anonymous

How do delete the Angle Constraint of Selected Components in Assembly ILogic

Anonymous
Not applicable

Hi,

I want to delete the Angle Constraint of Components which are selecting by me.

I have tried below Loop code but it showing attached error. Can you please help me to find the error in this code.

 

Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsm.ComponentDefinition
Line1 :
comp = ThisApplication.CommandManager.Pick(
SelectionFilterEnum.kAssemblyOccurrenceFilter,
"Select a components")
AngleConstraint.Delete(comp)
GoTo Line1

 

Thanks & Regards,

Manoj Sampath

0 Likes
Reply
Accepted solutions (1)
1,127 Views
10 Replies
Replies (10)

Yijiang.Cai
Autodesk
Autodesk

Please try the code sample below in the iLogic rule -

Dim oAsm As AssemblyDocument
oAsm = ThisApplication.ActiveDocument
	
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsm.ComponentDefinition

Line1:
Dim oComp As ComponentOccurrence
oComp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a components")

Dim oCons As AssemblyConstraint

For Each oCons In oComp.Constraints
    If oCons.Type = kAngleConstraintObject Or oCons.Type = kAngleConstraintProxyObject Then
        oCons.Delete
    End If
Next

GoTo Line1
Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com

Anonymous
Not applicable

@Yijiang.Cai 

Hi,

Thanks for your reply,

I have faced attached error while select the components. Can you please check and give your suggestion.

Thanks & Regards,

Manoj Sampath 

0 Likes

Yijiang.Cai
Autodesk
Autodesk

Please use the updated one, and it should be fixed. If it works for you, please accept it as solution.

 

Dim oAsm As AssemblyDocument
oAsm = ThisApplication.ActiveDocument
	
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsm.ComponentDefinition

Line1 :

Dim oComp As ComponentOccurrence
oComp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a components")

If oComp Is Nothing Then
	Exit Sub
End If

Dim oCons As AssemblyConstraint

For Each oCons In oComp.Constraints
    If oCons.Type = kAngleConstraintObject Or oCons.Type = kAngleConstraintProxyObject Then
        oCons.Delete
    End If
Next

GoTo Line1 

 

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
0 Likes

Anonymous
Not applicable

@Yijiang.Cai 

Hi,

Now the error message is not coming, But the Angle constraint not get delete.

I'm working on the Code you have suggested, Please update me if you get solution for this.

Thanks & Regards,

Manoj Sampath

0 Likes

Yijiang.Cai
Autodesk
Autodesk

Sorry for my typo when copying the code sample in the second reply from me, and I have updated it. Please copy the code sample in my second reply, and have a try.

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
0 Likes

Anonymous
Not applicable

@Yijiang.Cai 

I have used below Code, Is this the one you mention?

Angle constraints not deleting by this code.

Thanks  & Regards,\

Manoj Sampath

0 Likes

Yijiang.Cai
Autodesk
Autodesk

Could you copy and paste the code sample you use here?

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
0 Likes

Anonymous
Not applicable

@Yijiang.Cai 

Sorry. Below is the code

 

Dim oAsm As AssemblyDocument
oAsm = ThisApplication.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsm.ComponentDefinition

Line1 :

Dim oComp As ComponentOccurrence
oComp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a components")

If oComp Is Nothing Then
Exit Sub
End If

Dim oCons As AssemblyConstraint

For Each oCons In oComp.Constraints
If oCons.Type = kAngleConstraintObject Or oCons.Type = kAngleConstraintProxyObject Then
oCons.Delete
End If
Next

GoTo Line1

0 Likes

Yijiang.Cai
Autodesk
Autodesk
Accepted solution

It works for me when using the code sample. What release of Inventor you are using now?

Dim oAsm As AssemblyDocument
oAsm = ThisApplication.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsm.ComponentDefinition

Line1 :

Dim oComp As ComponentOccurrence
oComp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a components")

If oComp Is Nothing Then
Exit Sub
End If

Dim oCons As AssemblyConstraint

For Each oCons In oComp.Constraints
If oCons.Type = Inventor.ObjectTypeEnum.kAngleConstraintObject Or oCons.Type = Inventor.ObjectTypeEnum.kAngleConstraintProxyObject Then
oCons.Delete
End If
Next

GoTo Line1
Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com

Anonymous
Not applicable

@Yijiang.Cai 

This Code Working for me Now. Thanks for your help.

Thanks & Regards,

Manoj Sampath

0 Likes