Sweep Feature using sketches Profile and path

Sweep Feature using sketches Profile and path

florian_wenzel
Advocate Advocate
835 Views
5 Replies
Message 1 of 6

Sweep Feature using sketches Profile and path

florian_wenzel
Advocate
Advocate

Hi,

 

Inventor 2022  API with Visual Studio

i try to make a Sweep Feature with using existing sketches, path and Profile.

 

This is my Code:

Imports System.Runtime.InteropServices
Imports Inventor
Imports Microsoft.Win32


Module CommandFunctionButton_08

Public Sub CommandFunctionfweButton_08()

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


Dim oSketchLine1 As Object
oSketchLine1 = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select sketch line")


Dim oPathline As Path
oPathline = oCompDef.Features.CreatePath(oSketchLine1)

Dim oSectionSketch01 As Object
oSectionSketch01 = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select sketch Section")


Dim oProfile As Profile
oProfile = oSectionSketch01.Profiles.AddForSolid


Dim oSweep As SweepFeature
oSweep = oCompDef.Features.SweepFeatures.AddUsingPath(oProfile, oPathline, PartFeatureOperationEnum.kJoinOperation)

 

End Sub

End Module

 

What is wrong?

 

florianwenzelEJNZZ_0-1650199450342.png

 

Thanks for any Suggestion.

 

 

 

0 Likes
Accepted solutions (1)
836 Views
5 Replies
Replies (5)
Message 2 of 6

Ralf_Krieg
Advisor
Advisor

Hello

 

I know, the API help contains an example using the AddUsingPath method, but this is not ducumented anywhere else. Can you try to create a SweepDefinition and use it, like described in this blogpost?

https://adndevblog.typepad.com/manufacturing/2015/10/create-a-sweepfeature-with-path.html 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 6

florian_wenzel
Advocate
Advocate

Hi,

no, this not the solution.

the error start befor going to Sweep Feature

 

The Sweep Definition is not the problem.

The selecting the sketches

 

 

CODE:

 

Imports System.Runtime.InteropServices
Imports Inventor
Imports Microsoft.Win32


Module CommandFunctionButton_08

Public Sub CommandFunctionfweButton_08()

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


Dim oSketchLine1 As Object
oSketchLine1 = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select sketch line")


Dim oPathline As Path
oPathline = oCompDef.Features.CreatePath(oSketchLine1)

Dim oSectionSketch01 As Object
oSectionSketch01 = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select sketch Section")


Dim oProfile As Profile
oProfile = oSectionSketch01.Profiles.AddForSolid

 

Dim oSweepDef As SweepDefinition
oSweepDef = oCompDef.Features.SweepFeatures.CreateSweepDefinition(SweepDefinitionTypeEnum.kPathAndGuideRailSweepDef, oProfile, oPathline, PartFeatureOperationEnum.kCutOperation)

Dim oSweepOne As SweepFeature
oSweepOne = oCompDef.Features.SweepFeatures.Add(oSweepDef)

End Sub

End Module

0 Likes
Message 4 of 6

JelteDeJong
Mentor
Mentor

Try this iLogic rule:

Dim doc As PartDocument = ThisDoc.Document

Dim profile As Profile = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter, "Select profile")
Dim curve As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchCurveFilter, "Select sketch line")

Dim features = doc.ComponentDefinition.Features

Dim path As Path = features.CreatePath(curve)

Dim sweepFeatures = features.SweepFeatures
Dim sweepDefinition = sweepFeatures.CreateSweepDefinition(SweepTypeEnum.kPathSweepType, profile, path, PartFeatureOperationEnum.kNewBodyOperation)
sweepFeatures.Add(sweepDefinition)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 6

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

If you know where the code error's out, why don't you say it and post the error message?

We can not code a complete AddIn just to integrate and test your code.

The code to create a sweepdefinition is no correct too. SweepTypeDefEnum instead SweepTypeEnum, kCutOperation instead kJoinOperation - This can not work.

Thanks to @JelteDeJong pointing the pick method has  select filters for sketchprofiles/sketchcurves you need to use.

 

Anyway, try copy'n paste

Module CommandFunctionButton_08

Public Sub CommandFunctionfweButton_08()

Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition

Dim oSketchLine1 As Object= g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchCurveFilter, "Select sketch line")
Dim oPathline As Path = oCompDef.Features.CreatePath(oSketchLine1)
Dim oProfile As Profile= g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter, "Select sketch Section")
Dim oSweepDef As SweepDefinition = oCompDef.Features.SweepFeatures.CreateSweepDefinition(SweepTypeEnum.kPathSweepType , oProfile, oPathline, PartFeatureOperationEnum.kJoinOperation )
Dim oSweepOne As SweepFeature = oCompDef.Features.SweepFeatures.Add(oSweepDef)

End Sub

End Module

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 6 of 6

florian_wenzel
Advocate
Advocate

Hi,

yes!

 

PartFeatureOperationEnum.kCutOperation, copy past reason.

 

Thank you!

 

 

0 Likes