@L_Schwotzer
This should do it then 🙂
Dim oDoc As PartDocument = ThisDoc.Document
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oSketchPlane As WorkPlane = oDef.WorkPlanes.Item("XY Plane")
Dim oSketch As PlanarSketch = oDef.Sketches.Add(oSketchPlane)
Dim oFileName As String = "C:\TEMP\Test.xlsx" 'Excel file
Dim oSheetName As String = "Sheet1" 'Sheet name
GoExcel.Open(oFileName, oSheetName)
Dim i As Integer = 2
Dim oProfiles As New Dictionary(Of Double, ObjectCollection)
Dim UoM As UnitsOfMeasure = oDoc.UnitsOfMeasure
While True
Try
Dim oX As Double = UoM.ConvertUnits(CDbl(GoExcel.CellValue("A" & i)), UoM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)
Dim oY As Double = UoM.ConvertUnits(CDbl(GoExcel.CellValue("B" & i)), UoM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)
Dim oDia As Double = UoM.ConvertUnits(CDbl(GoExcel.CellValue("C" & i)), UoM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)
Dim oextDist As Double = UoM.ConvertUnits(CDbl(GoExcel.CellValue("D" & i)), UoM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)
Dim oPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oX, oY)
Dim oCircle As SketchCircle = oSketch.SketchCircles.AddByCenterRadius(oPoint, oDia / 2)
oSketch.GeometricConstraints.AddGround(oCircle.CenterSketchPoint)
oSketch.DimensionConstraints.AddDiameter(oCircle, ThisApplication.TransientGeometry.CreatePoint2d( _
oCircle.CenterSketchPoint.Geometry.X - oDia, oCircle.CenterSketchPoint.Geometry.Y + oDia))
If oProfiles.ContainsKey(oextDist)
oProfiles.Item(oextDist).Add(oCircle)
Else
Dim oCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oCol.Add(oCircle)
oProfiles.Add(oextDist, oCol)
End If
i += 1
Catch
Exit While
End Try
End While
Dim oExtrudes As ExtrudeFeatures = oDef.Features.ExtrudeFeatures
For Each oPair As KeyValuePair(Of Double, ObjectCollection) In oProfiles
Dim extDef As ExtrudeDefinition = oExtrudes.CreateExtrudeDefinition(oSketch.Profiles.AddForSolid(False, oPair.Value), PartFeatureOperationEnum.kJoinOperation)
extDef.SetDistanceExtent(oPair.Key, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
oExtrudes.Add(extDef)
Next
'Ground plate
Dim gX As Double = 0
Dim gY As Double = 0
Dim gDia As Double = UoM.ConvertUnits(CDbl(GoExcel.CellValue("F2")), UoM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)
Dim gExt As Double = UoM.ConvertUnits(CDbl(GoExcel.CellValue("G2")), UoM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)
Dim oGroundCircle As SketchCircle = oSketch.SketchCircles.AddByCenterRadius(ThisApplication.TransientGeometry.CreatePoint2d(), _
gDia / 2)
oSketch.GeometricConstraints.AddGround(oGroundCircle.CenterSketchPoint)
oSketch.DimensionConstraints.AddDiameter(oGroundCircle, ThisApplication.TransientGeometry.CreatePoint2d( _
oGroundCircle.CenterSketchPoint.Geometry.X - gDia, oGroundCircle.CenterSketchPoint.Geometry.Y + gDia))
Dim gCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
gCol.Add(oGroundCircle)
Dim oGroundDef As ExtrudeDefinition = oExtrudes.CreateExtrudeDefinition(oSketch.Profiles.AddForSolid(False, gCol), PartFeatureOperationEnum.kJoinOperation)
oGroundDef.SetDistanceExtent(gExt, _
PartFeatureExtentDirectionEnum.kNegativeExtentDirection)
oExtrudes.Add(oGroundDef)
GoExcel.Close
oDoc.Update