- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Delete workpoints and workaxis using API
Hello,
I am trying to delete the work points but getting an unspecified error in the delete line.
public static void DeletePoints(string wpoint)
{
AssemblyComponentDefinition assCompDef = assyDoc.ComponentDefinition;
for (int i = 1; i <= assCompDef.WorkPoints.Count; i++)
{
try
{
if (assCompDef.WorkPoints[i].Name== wpoint)
{
assCompDef.WorkPoints[i].Delete();
}
}
catch (Exception)
{
}
}
}
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is because some workpoints is undeletable (Origin workpoint for example) and work point collection changes after each delete. Use following iLogic snippet for delete all workpoints in part. You need to translate it to C#.
Dim part As PartDocument = ThisDoc.Document
Dim wPoints As WorkPoints = part.ComponentDefinition.WorkPoints
Dim undeletablePoints As Integer = 0
Do While wPoints.Count > undeletablePoints
Dim wPoint As WorkPoint = wPoints(undeletablePoints + 1)
Try
wPoint.Delete()
Catch
undeletablePoints += 1
End Try
Loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks @Michael.Navara for the quick reply. But the below code does not delete the work points. It goes to the catch statement and adds on undeletablePoints.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This code deletes all workpoints which can be deleted. Some workpoints can't be deleted. Part origin, USS origins, derived workpoints, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @nishantkumat5921 the delete method will fail for derived parts . Check this link for inventor docs
Inventor 2022 Help | WorkPoint.Delete Method | Autodesk

Fidel Makatia
Developer Advocate
href=https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-0BD48573-7193-4285-87B7-6727555D053E rel= "noopener noreferrer">Inventor 2022 Documentation |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @fidel.makatiaD5W7V I have tried both the Booleans option and still get an unspecified error. The part is not derived.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can you provide a screenshot of the workpoints location in the assembly?
Or if this helped you, please, click (like)
Regards
Alan