iLogic - Rename workpoints in patterns

iLogic - Rename workpoints in patterns

r.claus
Contributor Contributor
336 Views
2 Replies
Message 1 of 3

iLogic - Rename workpoints in patterns

r.claus
Contributor
Contributor

Hello,

I try to rename workpoints within a rectangular pattern (see picture). This pattern or collection is created with a another collection of workpoints.

My problem is that the code only change the names of the first workpoints in each element.
Is there a way to change all the names?

 

'Set the document
Dim oDoc As PartDocument
oDoc = ThisDoc.Document

'Set the component definition
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

'Set the circular pattern features collection

Dim oCircularPatternFeature As CircularPatternFeature
oCircularPatternFeature = oCompDef.Features.CircularPatternFeatures.Item("PointPattern")

 Dim oElement As FeaturePatternElement
 
 	For Each oElement In oCircularPatternFeature.PatternElements
		If oElement.Index = 1 Then
			'do nothing
		Else
			Dim oworkpoint As WorkPoint
			oworkpoint = oElement.ResultFeatures.Item(1)
			oworkpoint.Name = "TestPoint" & oElement.Index
		End If
	Next 
ThisDoc.Document.Update

 

0 Likes
Accepted solutions (1)
337 Views
2 Replies
Replies (2)
Message 2 of 3

TomaszDąbrowski
Enthusiast
Enthusiast
Accepted solution

I am not sure if I understand your idea, but please try if this code works.

'Set the document
Dim oDoc As PartDocument
oDoc = ThisDoc.Document

'Set the component definition
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

'Set the circular pattern features collection

Dim oCircularPatternFeature As CircularPatternFeature
oCircularPatternFeature = oCompDef.Features.CircularPatternFeatures.Item("PointPattern")

 Dim oElement As FeaturePatternElement

Dim i As Integer
Dim k As Integer = 1
 	For Each oElement In oCircularPatternFeature.PatternElements
		If oElement.Index = 1 Then
			'do nothing
		Else
				For i = 1 To oElement.ResultFeatures.count
			Dim oworkpoint As WorkPoint
			oworkpoint = oElement.ResultFeatures.Item(i)
			oworkpoint.Name = "TestPoint" & k
			k=k+1
				Next
		End If
	Next 
ThisDoc.Document.Update
0 Likes
Message 3 of 3

r.claus
Contributor
Contributor
Hello,

thanks for your fast help.
I had forgotten that I have rectangular patterns but I just change this and your code works.

Thank you very much 🙂
0 Likes