Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have Inventor 2023.
This is my path to be sweeped. The path is a 3D sketch. When i use the UI it works just fine.
Now my code always fails to make a sweeppath. It fails at line 22, because it can't create a path. I already tried filtering out everything exept the usable lines so it just uses the 3dArcs and 3D lines. I'm not an Ilogic expert. Can someone help me?
'=========== Begin iLogic Rule ===========
Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
' Create the sweep profile from a 2D sketch named "ProfileSketch".
Dim oSweepProfile As Profile = oCompDef.Sketches.Item("ProfileSketch").Profiles.AddForSolid()
' Retrieve the 3D sketch containing the sweep path curves.
Dim oSweepPathSketch As Sketch3D = oCompDef.Sketches3D.Item("PathSketch")
' Create an ObjectCollection and add all SketchLine3D and SketchArc3D entities.
Dim oColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
Dim oEnt As Object
For Each oEnt In oSweepPathSketch.SketchEntities3D
If TypeOf oEnt Is Inventor.SketchLine3D Or TypeOf oEnt Is Inventor.SketchArc3D Then
oColl.Add(oEnt)
End If
Next
' Create a continuous path from the collected entities.
Dim oSweepPath As Path = oCompDef.Features.CreatePath(oColl)
' Create the sweep feature using the profile and the sweep path.
Dim oSweepFeatures As SweepFeatures = oCompDef.Features.SweepFeatures
Dim oSweepDef As SweepDefinition = oSweepFeatures.CreateSweepDefinition( _
SweepTypeEnum.kPathSweepType, _
oSweepProfile, _
oSweepPath, _
PartFeatureOperationEnum.kNewBodyOperation)
Dim oSweep As SweepFeature = oSweepFeatures.Add(oSweepDef)
'=========== End iLogic Rule ===========
This will be part of an automated workflow so the manually making the sweep is not an option.
In advance: thank you for helping me!
Solved! Go to Solution.