I am looking for a way to transfer both WorkPoints and WorkAxis attributes from an iPart to an assembly which uses member parts derived from the iPart Factory. I have been successful in doing this for Edge and Face attributes in the following way, however this approach doesn't work for WorkPoints and WorkAxes.
The following procedure works well to transfer attributes for Edges
Public Sub CopyEdgeAttributes(ByVal app As Inventor.Application)
Dim oAsmDoc As AssemblyDocument
Dim oOcc As ComponentOccurrence
Dim oOccEdges As Edges
Dim oFactoryDoc As PartDocument
Dim oNativeEdges As Edges
oAsmDoc = app.ActiveDocument
oOcc = oAsmDoc.ComponentDefinition.Occurrences.item(1)
oOccEdges = oOcc.SurfaceBodies.item(1).Edges
oFactoryDoc = oOcc.Definition.iPartMember.ParentFactory.Parent
oNativeEdges = oFactoryDoc.ComponentDefinition.SurfaceBodies.item(1).Edges
Dim i As Long
For i = 1 To oNativeEdges.count
Dim oEdgePx As EdgeProxy
oEdgePx = oOccEdges.item(i)
Dim oAttributeSet As AttributeSet
For Each oAttributeSet In oNativeEdges(i).AttributeSets
Dim oNewAttSet As AttributeSet
oNewAttSet = oEdgePx.AttributeSets.Add(oAttributeSet.name)
Dim oAttribute As Inventor.Attribute
For Each oAttribute In oAttributeSet
oNewAttSet.Add(oAttribute.name, oAttribute.ValueType, oAttribute.Value)
Next
Next
Next
End Sub
Hi Peter,
Depending on the the type of changes an iPart parameter change can cause in your parts it might not be very robust to rely on the order of the edges and faces in the derived part/ipart instance.
Here is a blog post which might be helpful:
Cheers,
Many thanks for an informative and well writtten article. I missed your response the first time around so apologise for a late reply.
Best regards
Peter