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

Create a workfeature in a Part FROM an Assembly

Using the API, can I create a workpoint in a Part, using the face of that Part selected within its Parent Assembly?

(to reiterate, I want to select the Part in the Assembly, and the workfeature MUST be created in the Part NOT the Assembly)

 

I can get the Face using 

oFace = oApp.CommandManager.Pick(Inventor.SelectionFilterEnum.kPartFaceFilter, "Pick Face")

 

I can get the Part using

Dim oOcc As Inventor.ComponentOccurrence
oOcc = oFace.ContainingOccurrence
Dim oPartCompDef As Inventor.PartComponentDefinition
oPartCompDef = oOcc.Definition

 

But I cannot create a workpoint

Dim outerLoop As Inventor.EdgeLoop = Nothing
For Each outerLoop In oFace.EdgeLoops
If outerLoop.IsOuterEdgeLoop Then
Exit For
End If
Next

Dim oWorkPoint As Inventor.WorkPoint

oWorkPoint = oPartCompDef.WorkPoints.AddAtCentroid(outerLoop)

 

oWorkpoint comes back equalling 'Nothing'

 

Thanks in advance


MattH
Product Design Collection 2025
Vault Pro 2025
MattH_Work
in reply to: MattH_Work

Typical, you struggle for ages, post it on the forum and fix it straight away!!!

 

For Each outerLoop In oFace.EdgeLoops

 

should be

 

For Each outerLoop In oFace.NativeObject.EdgeLoops


MattH
Product Design Collection 2025
Vault Pro 2025