Anonymous
361 Views, 1 Reply
06-30-2016
02:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-30-2016
02:46 AM
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.
Solved! Go to Solution.
Anonymous
in reply to:
Anonymous
07-05-2016
06:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-05-2016
06:31 AM
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.