Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Macro to create a revolved part

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
isocam
483 Views, 3 Replies

Macro to create a revolved part

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

3 REPLIES 3
Message 2 of 4
ekinsb
in reply to: isocam

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

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 4
jdkriek
in reply to: ekinsb

Brian, there is a revolve example in help but it's kind of hidden under the Features Object

 

revolvesample.PNG

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 4 of 4
bravaiser
in reply to: jdkriek

You mention a " example in help" where is such help??? Thank you I am new...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report