Community
Can anyboy help?
Does anybody have an example macro that can create a new sketch, add a few lines and arcs, Then revolve the sketch around an axis to create a solid part. For example a shaft?
Many thanks in advance!!!
IsoCAM
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
I was surprised there wasn't a sample in the online help. Here's a simple one I just wrote.
Public Sub CreateRevolve() ' Create a new part. Dim partDoc As PartDocument Set partDoc = ThisApplication.Documents.Add(kPartDocumentObject, _ ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject)) Dim partDef As PartComponentDefinition Set partDef = partDoc.ComponentDefinition ' Create a sketch on the x-y plane. Dim sk As PlanarSketch Set sk = partDef.Sketches.Add(partDef.WorkPlanes.Item(3)) Dim tg As TransientGeometry Set tg = ThisApplication.TransientGeometry ' Draw some geometry. Dim points(5) As SketchPoint Set points(0) = sk.SketchPoints.Add(tg.CreatePoint2d(0, 0), False) Set points(1) = sk.SketchPoints.Add(tg.CreatePoint2d(5, 0), False) Set points(2) = sk.SketchPoints.Add(tg.CreatePoint2d(5, 2), False) Set points(3) = sk.SketchPoints.Add(tg.CreatePoint2d(4, 2), False) Set points(4) = sk.SketchPoints.Add(tg.CreatePoint2d(4, 3), False) Set points(5) = sk.SketchPoints.Add(tg.CreatePoint2d(0, 3), False) Dim centerLine As SketchLine Set centerLine = sk.SketchLines.AddByTwoPoints(points(0), points(1)) Call sk.SketchLines.AddByTwoPoints(points(1), points(2)) Call sk.SketchArcs.AddByCenterStartEndPoint(points(3), points(2), points(4)) Call sk.SketchLines.AddByTwoPoints(points(4), points(5)) Call sk.SketchLines.AddByTwoPoints(points(5), points(0)) ' Create a profile from the sketch. Dim prof As Profile Set prof = sk.Profiles.AddForSolid ' Create the revolution. Dim rev As RevolveFeature Set rev = partDef.Features.RevolveFeatures.AddFull(prof, centerLine, kJoinOperation) End Sub