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.
Solved by Sergio.D.Suárez. Go to Solution.
SweepDefinition is the missing link here.
Define a SweepDefinition object and use SweepFeatures.CreateSweepDefinition
Use that to create the sweep with the Add command.
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)
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
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.
Can't find what you're looking for? Ask the community or share your knowledge.