Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Inventor 2022
API VB.NET VisualStudio
i try to use the Pattern Elements from my Rectangular Pattern, but without succes.
In Part Enviroment, i want to Pattern a WorkPlane 5 Times, fit to Path Lenght.
This Works.
Then i want to have Acces to the 2 or 3 WorkPlane from Pattern Elements, how to do this?
This is my Code:
Imports System.Runtime.InteropServices
Imports Inventor
Imports Microsoft.Win32
Imports System.Collections.Generic
Imports System.Linq
Module CommandFunctionButton_12
Public Sub CommandFunctionfweButton_12()
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
'Pick the Line
Dim oLine As SketchLine = CType(g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchCurveLinearFilter, "Pick a Line"), SketchLine)
'Create Start point
Dim oPoint As SketchPoint
oPoint = oLine.StartSketchPoint
'Create WorkPlane
Dim oWorkplane As WorkPlane
oWorkplane = oCompDef.WorkPlanes.AddByNormalToCurve(oLine, oPoint)
'Create Object Coll for WorkPlane
Dim oObjColl_01 As ObjectCollection
oObjColl_01 = oTO.CreateObjectCollection
oObjColl_01.Add(oWorkplane)
'Create Path
Dim oPath As Path = oCompDef.Features.CreatePath(oLine)
Dim Count As Object = 5
'Create Pattern Def
Dim oRectPatternDef As RectangularPatternFeatureDefinition
oRectPatternDef = oCompDef.Features.RectangularPatternFeatures.CreateDefinition(oObjColl_01, oPath, True, Count, PatternSpacingTypeEnum.kFitToPathLength)
oRectPatternDef.XDirectionSpacingType = PatternSpacingTypeEnum.kFitToPathLength
oRectPatternDef.OrientationMethod = PatternOrientationEnum.kAdjustToDirection1
'Create Pattern Feature
Dim oRectPattern As RectangularPatternFeature
oRectPattern = oCompDef.Features.RectangularPatternFeatures.AddByDefinition(oRectPatternDef)
'till this Moment Works Fine
Dim oObjColl_Pattern As ObjectCollection
oObjColl_Pattern = oTO.CreateObjectCollection
oObjColl_Pattern.Add(oRectPattern.PatternElements)
''For Each oWorkPlaneColl As WorkPlane In oRectPattern.PatternElements()
'' oObjColl_Pattern.Add(oWorkPlaneColl)
''Next
Dim oWorkPlane_02 As WorkPlane
oWorkPlane_02 = oObjColl_Pattern(2)
Dim oWorkPlane_03 As WorkPlane
oWorkPlane_03 = oObjColl_Pattern(3)
Dim oSketch_01 As PlanarSketch
oSketch_01 = oCompDef.Sketches.Add(oWorkplane)
Dim oSketch_02 As PlanarSketch
oSketch_02 = oCompDef.Sketches.Add(oWorkPlane_02)
Dim oSketch_03 As PlanarSketch
oSketch_03 = oCompDef.Sketches.Add(oWorkPlane_03)
Dim oCenterPoint_01 As SketchPoint
oCenterPoint_01 = oSketch_01.SketchPoints.Add(oTG.CreatePoint2d(0, 0))
Dim oCenterPoint_02 As SketchPoint
oCenterPoint_02 = oSketch_02.SketchPoints.Add(oTG.CreatePoint2d(0, 0))
Dim oCenterPoint_03 As SketchPoint
oCenterPoint_03 = oSketch_03.SketchPoints.Add(oTG.CreatePoint2d(0, 0))
Dim oCircle_01 As SketchCircle
oCircle_01 = oSketch_01.SketchCircles.AddByCenterRadius(oCenterPoint_01, 1)
Dim oCircle_02 As SketchCircle
oCircle_02 = oSketch_02.SketchCircles.AddByCenterRadius(oCenterPoint_02, 2)
Dim oCircle_03 As SketchCircle
oCircle_03 = oSketch_03.SketchCircles.AddByCenterRadius(oCenterPoint_03, 3)
End Sub
End Module
Thanks for any Sugesstion
Solved! Go to Solution.