Sketch - Rectangular & Circular Arrays

Sketch - Rectangular & Circular Arrays

isocam
Collaborator Collaborator
1,030 Views
11 Replies
Message 1 of 12

Sketch - Rectangular & Circular Arrays

isocam
Collaborator
Collaborator

Can anybody help!

 

I am extracting all coordinates of sketch entities (eg  Line start & end points, arc centre radius start and end angle etc)

 

Everything is OK except that I have come across a ipt file containing a sketch that is copied in a "Rectangular Array".

 

Is there any way I can get the Rectangular & Circular Arrays dimensional date (eg Number of rows, number of columns, pitch etc)?

 

Many thanks in advance!!!

 

IsoCAM

0 Likes
1,031 Views
11 Replies
Replies (11)
Message 2 of 12

Vladimir.Ananyev
Alumni
Alumni

Will you please upload a sample model to simplify test.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 12

isocam
Collaborator
Collaborator

Please find,attached, a sample file.

 

 

0 Likes
Message 4 of 12

Vladimir.Ananyev
Alumni
Alumni

RectPattern.PNG

Rectangular pattern is controlled by RectangularPatternFeature object. 

The following VBA sample illustrates several properties of this object.

The complete description you may find in the Inventor API Help.

Private Sub Test_RectPattern()

  Dim oDoc As PartDocument
  Set oDoc = ThisApplication.ActiveDocument
  Dim oDef As PartComponentDefinition
  Set oDef = oDoc.ComponentDefinition
  
  'reference to rect. pattern
  Dim oRP As RectangularPatternFeature
  Set oRP = oDef.Features.RectangularPatternFeatures _
              .Item("Rectangular Pattern1")
  
  Dim oPar As Inventor.Parameter
  
  'number of elements along X and Y
  Set oPar = oRP.XCount
  Debug.Print "XCount = " & oPar.Value & "  Par: " & oPar.Name
  Set oPar = oRP.YCount
  Debug.Print "YCount = " & oPar.Value & "  Par: " & oPar.Name
  
  'Spacing (cm) along X and Y
  Set oPar = oRP.XSpacing
  Debug.Print "XSpacing(cm) = " & oPar.Value & "  Par: " & oPar.Name
  Set oPar = oRP.YSpacing
  Debug.Print "YSpacing(cm) = " & oPar.Value & "  Par: " & oPar.Name
  
  'reference to feature
  Dim oObjColl As ObjectCollection
  Set oObjColl = oRP.ParentFeatures
  Dim oExtr As ExtrudeFeature
  Set oExtr = oObjColl.Item(1)
  Debug.Print "Feature = " & oExtr.Name
  
  'references to all pattern elements
  Dim i As Integer
  Dim oFPE As FeaturePatternElement
  For i = 1 To oRP.PatternElements.Count
    Set oFPE = oRP.PatternElements.Item(i)
    Debug.Print i & "  Suppressed: " & oFPE.Suppressed
  Next i

End Sub

 Result with your model:

XCount =        2  Par: d12
YCount =        2  Par: d15
XSpacing(cm) = 25  Par: d14
YSpacing(cm) = 31  Par: d17
Feature = Extrusion2
1  Suppressed: False
2  Suppressed: False
3  Suppressed: False
4  Suppressed: False

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 12

isocam
Collaborator
Collaborator

Here is my "Function", so far...

 

Public Function ArrayGeometry(Doc As PartDocument)
  Dim oDef As PartComponentDefinition
 
  Set oDef = Doc.ComponentDefinition
 
  Dim oRP As RectangularPatternFeature

  Set oRP = oDef.Features.RectangularPatternFeatures.Item("Rectangular Pattern1")
 
  Dim oPar As Inventor.Parameter

  Select Case FeatureType
    Case "Rectangular"
         Set oPar = oRP.Xcount
         Xcount = oPar.Value
 
         Set oPar = oRP.Ycount
         Ycount = oPar.Value
 
         Set oPar = oRP.Xspacing
         Xspacing = oPar.Value * 10
  
         Set oPar = oRP.YSpacing
         YSpacing = oPar.Value * 10
           
         Dim i As Integer
 
         Dim oFPE As FeaturePatternElement
 
         For i = 1 To oRP.PatternElements.Count
             Set oFPE = oRP.PatternElements.Item(i)
    
             If oFPE.Suppressed = False Then Call RectangularArray
         Next i
    Case "Circular"

 

           ????

  End Sub
End Function

 

If I have more than one "Rectangular Array", how do I implement that and also What if the array is "Circular"

 

Can you help?

 

Kindest Regards

 

IsoCAM

0 Likes
Message 6 of 12

Vladimir.Ananyev
Alumni
Alumni

Features object has property for every kind of features. 

You can find references to all cirlular patterns via the following  property:

Features.CircularPatternFeatures() As CircularPatternFeatures.

See Inventor API Help article on CircularPatternFeature object.

 

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 7 of 12

isocam
Collaborator
Collaborator

Hi,

 

Can you give me an example vba macro that can do both "Rectangular" and "Circular" arrays?

 

Say my inventor part (ipt) has multiple "Rectangular" and "Circular" arrays. How can I get the array info (Number of repeats etc)

 

Many thanks!!

 

IsoCAM

0 Likes
Message 8 of 12

Vladimir.Ananyev
Alumni
Alumni

You should process RectangularPatternFeatures and CircularPatternFeatures collections separately.

Each collection has Item and Count properties.

Here is the sample for circular pattern:

 

Private Sub Test_CircPattern()

  Dim oDoc As PartDocument
  Set oDoc = ThisApplication.ActiveDocument
  Dim oDef As PartComponentDefinition
  Set oDef = oDoc.ComponentDefinition
  
  'reference to circular pattern directly by name
  Dim oCP As CircularPatternFeature
  Set oCP = oDef.Features.CircularPatternFeatures _
              .Item("Circular Pattern AAA")
  
  Dim oPar As Inventor.ModelParameter
  
  'extended name
  Debug.Print "Extended name:   " & oCP.ExtendedName
  
  'number of elements
  Set oPar = oCP.Count
  Debug.Print "Count = " & oPar.Value & "  Par: " & oPar.Name
  
  'angle
  Set oPar = oCP.Angle
  Debug.Print "Angle (rad) = " & oPar.Value & "  Par: " & oPar.Name
  
End Sub


Result:
Extended name:   (x 7 ul x 180 deg)
Count = 7  Par: d9
Angle = 3.14159265358979  Par: d10

 Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 9 of 12

isocam
Collaborator
Collaborator

Please refer to the attached Module. (Extension changed to txt)

 

My Inventor part (ipt) can have either a single "Rectangular" array, or a single "Circular" array or multiple "Rectangular" or "Circular" arrays.

 

At the moment it can only handle "Rectangular Pattern1" or". "Circular Pattern1"

 

How can the, attached, macro be changed so that it goes through each "Rectangular" or "Circular" array in turn.

 

Many thanks in advance!!!!

 

IsoCAM

0 Likes
Message 10 of 12

Vladimir.Ananyev
Alumni
Alumni

I think the framework of your procedure should be similar to the followng sample:

Public Sub PartPatterns()

  Dim oDoc As PartDocument
  Set oDoc = ThisApplication.ActiveDocument

  Dim oDef As PartComponentDefinition
  Set oDef = oDoc.ComponentDefinition

  'number of rect. patterns
  Dim N1 As Integer
  N1 = oDef.Features.RectangularPatternFeatures.Count
  
  'number of circ. patterns
  Dim N2 As Integer
  N2 = oDef.Features.CircularPatternFeatures.Count
  
  
  'process all rect. patterns
  '"""""""""""""""""""""""""""
  Debug.Print "   We have " & N1 & " rect. patterns:"
  
  Dim oRP As RectangularPatternFeature
  For Each oRP In oDef.Features.RectangularPatternFeatures

    'do everything you want with this oRP
    Debug.Print oRP.Name
    
  Next
  Debug.Print
  
  'process all circ. patterns
  '"""""""""""""""""""""""""""
  Debug.Print "   We have " & N2 & " circ. patterns:"
  
  Dim oCP As CircularPatternFeature
  For Each oCP In oDef.Features.CircularPatternFeatures
    
    'do everything you want with this oCP
    Debug.Print oCP.Name
    
  Next
  Debug.Print
  
End Sub

 Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 11 of 12

isocam
Collaborator
Collaborator

I have only one real issue with the macro. It arrays every sketch in my part

 

Is there a way of only allowing sketch entities to be "arrayed" if that sketch entity has an associated array attached to it?

 

I the sample there are holes spaced equally on a "pitch circle diameter" the holes are arrayed.

 

The output I am getting also arrays the first sketch, that is the circle that makes up the outer plate.

 

This sketch (sketch1) is also arrayed, even though the sketch does not have an associated array.

 

Is there a way to filter out sketches that do not have an associated array?

 

Many thanks in advance!!!!

 

IsoCAM

0 Likes
Message 12 of 12

Vladimir.Ananyev
Alumni
Alumni

If you need information on specific feature pattern you should use its name or pick it via UI (you do not need to use any sketches at all).

 

For example your part TestPlate.ipt includes the hole feature circular pattern.  This pattern is accessible by its name as it was shown in Sub Test_CircPattern()  posted on Nov-08-2012.

Name = “Circular Pattern1”

 

Your function Function ArrayGeometry(Doc As PartDocument, sketch As PlanarSketch) should have the feature pattern name in the second argument instead of the reference to the planar sketch.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes