- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
SweepDefinition is the missing link here.
Define a SweepDefinition object and use SweepFeatures.CreateSweepDefinition
Use that to create the sweep with the Add command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.