- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm glad it's working for you. I tried it both ways before posting it that last time, but couldn't get it to work for me, even though everything seemed to be in order. I still can't get either way to work. I created two different ObjectCollections this time. One for the Transient Point objects, and one for the SketchPoint3D objects. I've tried using both collections as the variable within both the SketchSplines3d.Add() and the SketchControlPointSplines3D.Add() functions. I've tried changing the sketch points from HoleCenter points to regular points (by changing True or False when creating them), but that didn't make any difference in either function. I tried commenting out all the sketch point creation and its collection object, and only creating a sketch3D object with nothing in it, then creating the splines from the transient points, but that wouldn't work for either function either. They both have very similar error messages, which interpreted to say that it ran into an error while trying to execute that last Add() function. It creates the Sketch3d, Creates all the points and sketch points, creates the collections, and adds them into the collections, but that last line always errors out. I can't quite understand why though. Maybe it doesn't like my point locations, and has a hard time creating a spline to fit them.
Here's my code now.
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oXLFile As String = "S:\Engineering\SHARED\Tests\Points To Import.xlsx"
Dim oSheet As String = "Sheet1"
GoExcel.Open(oXLFile, oSheet)
GoExcel.DisplayAlerts = False
GoExcel.TitleRow = 2
GoExcel.FindRowStart = 3
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oCoords(2) As Double
Dim oPoint As Point
Dim oSkPt3d As SketchPoint3D
Dim oPoints As ObjectCollection = oTO.CreateObjectCollection
Dim oSkPoints As ObjectCollection = oTO.CreateObjectCollection
Dim oSketch3d As Sketch3D = oPDef.Sketches3D.Add()
For i As Integer = 3 To 10
oCoords(0) = GoExcel.CellValue("A" & i)
oCoords(1) = GoExcel.CellValue("B" & i)
oCoords(2) = GoExcel.CellValue("C" & i)
oPoint = oTG.CreatePoint(oCoords(0), oCoords(1), oCoords(2))
oPoints.Add(oPoint)
oSkPt3d = oSketch3d.SketchPoints3D.Add(oPoint, True)
oSkPoints.Add(oSkPt3d)
Next
System.Threading.Thread.Sleep(1000)
Dim oSpline As SketchSpline3D = oSketch3d.SketchSplines3D.Add(oPoints,SplineFitMethodEnum.kSmoothSplineFit)
'Dim oSpline As SketchControlPointSpline3D = oSketch3d.SketchControlPointSplines3D.Add(oPoints)
Wesley Crihfield
(Not an Autodesk Employee)