Inventor Customization

Inventor Customization

Reply
New Member
r.hubregsen
Posts: 2
Registered: ‎05-15-2012
Message 1 of 3 (246 Views)
Accepted Solution

Help With Creating Circularpattern VBA

246 Views, 2 Replies
09-28-2012 07:37 AM

Does Anybody know how to create a circular pattern around the predefined Z axis. 

 

 

Private Sub createpattern()


Dim oCompdef As ComponentDefinition
Dim oDoc As PartDocument
Dim oSketch As PlanarSketch
Dim oPart As PartFeatures
Dim oProfile As Profile
Dim oExtrusion As ExtrudeFeature
Dim oDef As PartComponentDefinition
Dim objGeometry As TransientGeometry

Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject, , True)
Set oCompdef = oDoc.ComponentDefinition
Set oSketch = oCompdef.Sketches.Add(oCompdef.WorkPlanes.Item(3))
Set objGeometry = ThisApplication.TransientGeometry

Call oSketch.SketchLines.AddAsTwoPointRectangle(objGeometry.CreatePoint2d(1, 1), objGeometry.CreatePoint2d(7, 5))


Set oProfile = oSketch.Profiles.AddForSolid
Set oExtrusion = oCompdef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, 10, kSymmetricExtentDirection, kJoinOperation)


Call oPart.CircularPatternFeatures.Add(oPart.ExtrudeFeatures.Item(1), oDef.WorkAxes.Item(3), True, 3, 360, True)


End Sub

Hi mate,

 

Here you go...

 

Cheers

 

Jon

 

Private Sub createpattern()

Dim oDoc As PartDocument
    Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject, , True)

Dim oCompdef As ComponentDefinition
    Set oCompdef = oDoc.ComponentDefinition

Dim objGeometry As TransientGeometry
    Set objGeometry = ThisApplication.TransientGeometry

Dim oSketch As PlanarSketch
    Set oSketch = oCompdef.Sketches.Add(oCompdef.WorkPlanes.Item(3))

    Call oSketch.SketchLines.AddAsTwoPointRectangle(objGeometry.CreatePoint2d(1, 1), objGeometry.CreatePoint2d(7, 5))

Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid

Dim oExtrusion As ExtrudeFeature
    Set oExtrusion = oCompdef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, 10, kSymmetricExtentDirection, kJoinOperation)


Dim objCol As ObjectCollection
    Set objCol = ThisApplication.TransientObjects.CreateObjectCollection
'Feature to be patterned
    objCol.Add oCompdef.Features(1)
    oCompdef.Features.CircularPatternFeatures.Add objCol, oCompdef.WorkAxes.Item(3), True, 3, 360, True

End Sub

Valued Contributor
jonbrabbs
Posts: 76
Registered: ‎07-26-2007
Message 2 of 3 (241 Views)

Re: Help With Creating Circularpattern VBA

09-28-2012 08:33 AM in reply to: r.hubregsen

Hi mate,

 

Here you go...

 

Cheers

 

Jon

 

Private Sub createpattern()

Dim oDoc As PartDocument
    Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject, , True)

Dim oCompdef As ComponentDefinition
    Set oCompdef = oDoc.ComponentDefinition

Dim objGeometry As TransientGeometry
    Set objGeometry = ThisApplication.TransientGeometry

Dim oSketch As PlanarSketch
    Set oSketch = oCompdef.Sketches.Add(oCompdef.WorkPlanes.Item(3))

    Call oSketch.SketchLines.AddAsTwoPointRectangle(objGeometry.CreatePoint2d(1, 1), objGeometry.CreatePoint2d(7, 5))

Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid

Dim oExtrusion As ExtrudeFeature
    Set oExtrusion = oCompdef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, 10, kSymmetricExtentDirection, kJoinOperation)


Dim objCol As ObjectCollection
    Set objCol = ThisApplication.TransientObjects.CreateObjectCollection
'Feature to be patterned
    objCol.Add oCompdef.Features(1)
    oCompdef.Features.CircularPatternFeatures.Add objCol, oCompdef.WorkAxes.Item(3), True, 3, 360, True

End Sub

///////////////////////////////////////////////////////////////////////////////////////////////////
If this post helps you, please give kudos.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
New Member
r.hubregsen
Posts: 2
Registered: ‎05-15-2012
Message 3 of 3 (226 Views)

Re: Help With Creating Circularpattern VBA

10-01-2012 02:52 AM in reply to: jonbrabbs
Many thanks for the help Kind Regards Tech2Sea R. Hubregsen Tel: +31 (0)172 748046 [Beschrijving: Beschrijving: Tech2sea logo]
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.