- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
River Cai
Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
River Cai
Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
River Cai
Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have used below Code, Is this the one you mention?
Angle constraints not deleting by this code.
Thanks & Regards,\
Manoj Sampath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Could you copy and paste the code sample you use here?
River Cai
Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
River Cai
Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report