Circular or Rectangular Pattern "Sketch Name"

Circular or Rectangular Pattern "Sketch Name"

isocam
Collaborator Collaborator
600 Views
4 Replies
Message 1 of 5

Circular or Rectangular Pattern "Sketch Name"

isocam
Collaborator
Collaborator

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

0 Likes
Accepted solutions (1)
601 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

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!!!

0 Likes
Message 3 of 5

isocam
Collaborator
Collaborator

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

0 Likes
Message 4 of 5

Anonymous
Not applicable

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

0 Likes
Message 5 of 5

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

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

0 Likes