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: 

Circular or Rectangular Pattern "Sketch Name"

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
isocam
448 Views, 4 Replies

Circular or Rectangular Pattern "Sketch Name"

Can anybody help?

 

I need to know what sketch is associated to either a "Rectangular"or "Circular"array.

 

This is so I can filter out sketches that are not repeated in an array.

 

Here is my code so far (Circular Array).

 

Dim oCP As CircularPatternFeature

   For Each oCP In oDef.Features.CircularPatternFeatures
     THIS IS THE TROUBLE LINE  If sketch = oCP.Parent Then
          Set oCP = oDef.Features.CircularPatternFeatures.Item(oCP.Name)
         
          Set oPar = oCP.Count
          Xcount = oPar.Value

          Set oPar = oCP.Angle
  

          FitAngle = oPar.Value * Rad

 

          If FitAngle = 360 Then
             IncrementalAngle = 360 / Xcount
          Else
             IncrementalAngle = FitAngle / (Xcount - 1)
          End If
         
          For Counter = 1 To Xcount
              Set oFPE = oCP.PatternElements.Item(Counter)
 
              If oFPE.Suppressed = False Then
                 AbsoluteAngle = (Counter - 1) * IncrementalAngle

                 REM Call CircularArray
              End If
          Next Counter
       End If
   Next

 

I have a simple test part containing an extruded disk (Sketch1) and 8 holes on a pcd (Sketch2). I only want to array a sketch if it is arrayed,

 

Many thanks in advance!!!

 

IsoCAM

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: isocam

Hi isocam,

 

I would say that the Circular Array is the Parent of the Sketch. The way you have it written I believe you're asking if the sketch is the Parent of the Circular Array.

 

Regards

Mitch

 

Let me know if it helps... Kudos if it works!!!

Message 3 of 5
isocam
in reply to: isocam

Mitch,

 

Can you please give me a working example of the line of code I need to achieve this?

 

I cannot seem to get the correct code to do this!

 

Many thanks!!!!!

 

IsoCAM

Message 4 of 5
Anonymous
in reply to: isocam

Hi Isocam,

 

May I ask what exactly you are trying to do with the code? That way I have an idea when trying to fix it.

 

Regards

Mitch

Message 5 of 5
Vladimir.Ananyev
in reply to: Anonymous

Hi Isocam,

if you need a reference to the planar sketch where arrayed
geometry was sketched then look to these code samples:

 

Sub TEST_Rect()

  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 oParentFeature As ExtrudeFeature 'one of PartFeature
  Set oParentFeature = oRP.ParentFeatures.Item(1)
  
  Dim oSketch As PlanarSketch
  Set oSketch = oParentFeature.Profile.Parent
  
  Debug.Print "Parent sketch: " & oSketch.Name
  
End Sub



Sub TEST_Circ()

  Dim oDoc As PartDocument
  Set oDoc = ThisApplication.ActiveDocument
  Dim oDef As PartComponentDefinition
  Set oDef = oDoc.ComponentDefinition
  
  'reference to circ. pattern
  Dim oCP As CircularPatternFeature
  Set oCP = oDef.Features.CircularPatternFeatures _
              .Item("Circular Pattern1")
  
  Dim oParentFeature As ExtrudeFeature 'one of PartFeature
  Set oParentFeature = oCP.ParentFeatures.Item(1)
  
  Dim oSketch As PlanarSketch
  Set oSketch = oParentFeature.Profile.Parent
  
  Debug.Print "Parent sketch: " & oSketch.Name
  
End Sub

 In both cases it is assumed that patterns were created using ExtrudeFeature objects.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report