
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear big programming world!
I tried a RectangularPattern via VBA. I got it going in an assembly. But it only works with the work axes. Is there a way to let the pattern run along a unit vector or the like? How do I create a Rectangular Pattern in a Part and in an Assembly? How can I set a direction regardless of the work axes? Please help me. Thank you
' Set a reference to the active assembly document
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
' Set a reference to the AssemblyComponentDefinition
Dim oDef As AssemblyComponentDefinition
Set oDef = oDoc.ComponentDefinition
' Get the x\-axis of the assembly
Dim oXAxis As WorkAxis
Set oXAxis = oDef.WorkAxes.Item(1)
' Get the y\-axis of the assembly
Dim oYAxis As WorkAxis
Set oYAxis = oDef.WorkAxes.Item(2)
Dim oParentOccs As ObjectCollection
Set oParentOccs = ThisApplication.TransientObjects.CreateObjectCollection
oParentOccs.Add oDef.Occurrences.Item(1)
' Create a rectangular pattern of components\:
' 4 columns in the x\-direction with an offset of 5 in
' 3 rows in the y\-direction with an offset of 4 in
Dim oRectOccPattern As RectangularOccurrencePattern
Set oRectOccPattern = oDef.OccurrencePatterns.AddRectangularPattern( _
oParentOccs, oXAxis, True, "5 in", 4, oYAxis, True, "4 in", 3)
End Sub
Solved! Go to Solution.