Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
felix.cortes5K3Y2
1226 Views, 5 Replies

iLogic To Create Sweep

Hi Forum,

 

I want to create a sweep from two sketches but I do not know how to work it out.

 

So far, here's what I got

 

	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oSketch1 As Sketch = "Sketch1"
	Dim oSketch2 As Sketch = "Sketch2"
	Dim oCompDef As PartComponentDefinition
	oCompDef = oPartDoc.ComponentDefinition
	oSweep = oCompDef.Features.SweepFeatures.Add.....???

 

I'd like to create the sweep from oSketch1 and oSketch2 but do not know how to follow up the syntax to do so.

 

Best regards,

Felix Cortes

SweepDefinition is the missing link here.

Define a SweepDefinition object and use SweepFeatures.CreateSweepDefinition

Use that to create the sweep with the Add command.

jvj

Hi, To create a swepp with a single line route, for example, you could use something like this. Sketch1 is the sketch of the profile, and sketch2 is the sketch of the route.

 

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
' Create a profile.
Dim oSketch1 As Sketch = oCompDef.Sketches.Item("Sketch1")
Dim oProfile As Profile = oSketch1.Profiles.AddForSolid
' Create a path.
Dim oSketch2 As Sketch = oCompDef.Sketches.Item("Sketch2")
Dim oPath As Path = oCompDef.Features.CreatePath(oSketch2.SketchLines(1))

' Create the sweep feature.
Dim oSweep As SweepFeature = oCompDef.Features.SweepFeatures.AddUsingPath(oProfile, oPath, kJoinOperation)

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Thanks Sergio, this worked

Hey Sergio,

 

I am trying to add a Rectangular pattern onto the newly created sweep but it doesn't seem to work. Here's what I've tried so far:

 

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
' Create a profile.
Dim oSketch1 As Sketch = oCompDef.Sketches.Item("Sketch1")
Dim oProfile As Profile = oSketch1.Profiles.AddForSolid
' Create a path.
Dim oSketch2 As Sketch = oCompDef.Sketches.Item("Sketch2")
Dim oPath As Path = oCompDef.Features.CreatePath(oSketch2.SketchLines(1))

' Create the sweep feature.
Dim oSweep As SweepFeature = oCompDef.Features.SweepFeatures.AddUsingPath(oProfile, oPath, kJoinOperation)
oSweep.Name = "Test"

'Dim TestPattern As RectangularPatternFeature = oCompDef.Features.RectangularPatternFeatures.Add("TestPattern", 3, 20 in, Nothing, "X Axis")
'Dim TestPatter0 As RecantgularPatternFeature = oCompDef.Features.RectangularPatternFeatures
'TestPatter0.CreateDefinition("Test", "X Axis", True, 3, "20 in")
Dim TestPattern As RecantgularPatternFeature = oCompDef.Features.RectangularPatternFeatures.CreateDefinition("Test", "X Axis", True, 3, "20 in")

The code fails on the last line. 

It works perfectly fine to create a new sweep feature. However, could you provide me with a code to modify an existing sweep feature? For example, for 'Sweep1,' I want to change the profile and path without creating a new sweep.