Create Circular Pattern in assembly

Create Circular Pattern in assembly

Anonymous
Not applicable
389 Views
1 Reply
Message 1 of 2

Create Circular Pattern in assembly

Anonymous
Not applicable

I'm trying to pattern a component using another components axis in an assembly:

 

 

    Public Sub Pattern()
        Dim oADoc As AssemblyDocument = InvApp.ActiveEditDocument
        Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
        Dim InvPart1 As ComponentOccurrence = oADef.Occurrences.Item(1)
        Dim InvPart2 As ComponentOccurrence = oADef.Occurrences.Item(2)
        Dim oAxis As WorkAxis = InvPart1.Definition.workaxes(1)
        MsgBox("Part1 : " & InvPart1.Name & vbCr & "Part2 : " & InvPart2.Name & vbCr & "Axis : " & oAxis.Name)
        Dim oOccPatterns As OccurrencePatterns = oADef.OccurrencePatterns
        Call oOccPatterns.AddCircularPattern(InvPart2, oAxis, True, "45 deg", 8)
    End Sub

 

The message box proves that it is successfully finding the two compoents and the X Axis of the first component.

It keeps falling over on the last line, when trying to create the pattern, I've tried creating a workaxisproxy but found this made no difference.

 

attached is the assembly file I've been trying it out on

 

Any help with this would be great.

0 Likes
Accepted solutions (1)
390 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

For everyone's info, 

 

I've got this workaround:

 

        Dim oADoc As AssemblyDocument = InvApp.ActiveEditDocument
        Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
        Dim InvPart1 As ComponentOccurrence = oADef.Occurrences.Item(1)
        Dim Invpart1Def As PartComponentDefinition = InvPart1.Definition
        Dim InvPart2 As ComponentOccurrence = oADef.Occurrences.Item(2)

        Dim oObjects As ObjectCollection
        Dim oOccPatterns As OccurrencePatterns = oADef.OccurrencePatterns
        Dim oFeature As CircularPatternFeature
        Dim oFeatureProxy As CircularPatternFeatureProxy

        oObjects = InvApp.TransientObjects.CreateObjectCollection
        oObjects.Add(InvPart2)


        oFeature = Invpart1Def.Features.CircularPatternFeatures.Item(1)
        Call InvPart1.CreateGeometryProxy(oFeature, oFeatureProxy)
        Call oADef.OccurrencePatterns.AddFeatureBasedPattern(oObjects, oFeatureProxy)

    End Sub

 

This works with the assembly I posted, as long as the first item has a circular pattern to use.

0 Likes