Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Forum,
I am trying to create a pattern of a part inside an assembly based off a rectangular part feature from another part but can't seem to get the code to work. Here's what I have written so far:
Dim BrowserName As String = "SERPENTINE SHOE" 'the part that needs to be pattern Dim PatternBrowserName As String = BrowserName & "S" 'name of pattern that will be made Dim FeatureName As String = "Shoe Pattern" 'name of the feature Dim RefPartName As String = "SERPENTINE SPREADER FOR SHOE" 'name of the part with the feature Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument Dim oAsmComp As AssemblyComponentDefinition = oAsm.ComponentDefinition Dim oOcc As ComponentOccurrence Dim oOccPattern As OccurrencePattern Dim PartExists As Boolean = False Dim PatternExists As Boolean = False Dim oPattern As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection Dim n As Integer = 1 Dim RefExists As Boolean = False Dim oPartDoc As PartDocument Dim oPartComp As PartComponentDefinition Dim oFeat As PartFeature For Each oOcc In oAsmComp.Occurrences If oOcc.Name = BrowserName Then PartExists = True oPattern.Add(oAsmComp.Occurrences.Item(n)) Else If oOcc.Name = RefPartName Then RefExists = True oPartDoc = ThisApplication.Documents.Open(oOcc.ReferencedDocumentDescriptor.FullDocumentName, False) oPartComp = oPartDoc.ComponentDefinition oFeat = oPartComp.Features.RectangularPatternFeatures.Item(FeatureName) End If n = n + 1 Next '[ adds pattern into the assembly Dim oOccPtrns As OccurrencePatterns = oAsmComp.OccurrencePatterns Dim oPtrn As OccurrencePattern oPtrn = oOccPtrns.AddFeatureBasedPattern(oPattern, oFeat) oPtrn.Name = PatternBrowserName ']
Best,
Felix
Solved! Go to Solution.