
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey all!
I am having some trouble creating a sweep feature through the API.
Here's the skinny-
I have a sketch that define the end of a tube, and then a series of connected sketches that define the route of the tube on separate sketches and different planes (But they all are connected end to end). Currently, I manually create the sweep just fine, but I am trying to automate some of this.
With either of the sweep feature adding methods (one is commented out) I keep getting this error-
Run-Time Error, method 'add' of object 'sweepfeatures' failed
I tried to follow along with these to no avail
http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-20388027-7B42-4645-AE3D-F9528AB24EE4
Here is my code (the extrude stuff at the end works, it was just to see if my profile was usable)
Public Sub CreateSweep()
Dim PartDoc As PartDocument
Set PartDoc = ThisApplication.ActiveDocument
Dim PartDef As PartComponentDefinition
Set PartDef = PartDoc.ComponentDefinition
Dim oFeatures As Object
Set oFeatures = PartDef.Features
Dim oUserParams As UserParameters 'declare
Set oUserParams = PartDef.Parameters.UserParameters 'set to user params collection object
Dim NumBends As Integer 'set to desired parameter
NumBends = oUserParams.Item("NumBends").Value
'staggered bc of the sketch order
Dim lastSk As Integer
lastSk = NumBends + 2
PartDef.Sketches.Item(lastSk).SetEndOfPart (True)
'using first bend sketch to create path, all sketches before EOP should be included (in theory)
Dim oPath As Path
Set oPath = oFeatures.CreatePath(PartDef.Sketches.Item(3).SketchLines.Item(1))
'Set oPath = PartDef.Sketches.CreatePath(PartDef.Sketches.Item(3).SketchLines.Item(1))
'Set oPath = SweepDefinition.Path(PartDef.Sketches.Item(3))
'setting the end of tube sketch as the sweep profile
'need to somehow select the area between the two concentric circles only
Dim oProfile As Profile
Set oProfile = PartDef.Sketches.Item(1).Profiles.AddForSolid
'Set oProfile = PartDef.Sketches.Item(1)
'Set oProfile = SweepDefinition.Profile(PartDef.Sketches.Item(1).SketchLines.Item(1))
'attempt to add definition based on tube end profile and bend sketches
Dim oSweepDef As SweepDefinition
Set oSweepDef = oFeatures.SweepFeatures.CreateSweepDefinition(kPathSweepType, oProfile, oPath, PartFeatureOperationEnum.kJoinOperation)
'failed attempts to create the sweep
Dim oSweep As SweepFeature
Set oSweep = oFeatures.SweepFeatures.Add(oSweepDef)
'Set oSweep = oFeatures.SweepFeatures.AddUsingPath(oProfile, oPath, kJoinOperation)
'verifying sanity with an extrude
'Dim extrudeDef As ExtrudeDefinition
'Set extrudeDef = oFeatures.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
'Call extrudeDef.SetDistanceExtent(5, kPositiveExtentDirection)
'Dim extrude As ExtrudeFeature
'Set extrude = oFeatures.ExtrudeFeatures.Add(extrudeDef)
End Sub
TL:DR
Sweep feature fails. Help a brother out?
Thanks for looking!
D.M.
Solved! Go to Solution.