iLogic To Create Sweep

iLogic To Create Sweep

felix.cortes5K3Y2
Advocate Advocate
2,078 Views
5 Replies
Message 1 of 6

iLogic To Create Sweep

felix.cortes5K3Y2
Advocate
Advocate

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

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

JamieVJohnson2
Collaborator
Collaborator

SweepDefinition is the missing link here.

Define a SweepDefinition object and use SweepFeatures.CreateSweepDefinition

Use that to create the sweep with the Add command.

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 6

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

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

Message 4 of 6

felix.cortes5K3Y2
Advocate
Advocate

Thanks Sergio, this worked

0 Likes
Message 5 of 6

felix.cortes5K3Y2
Advocate
Advocate

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. 

0 Likes
Message 6 of 6

SeyedMostafavi
Explorer
Explorer

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.

0 Likes