12-07-2021
05:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-07-2021
05:38 AM
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
Solved! Go to Solution.
12-07-2021
05:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-07-2021
05:59 AM
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
12-07-2021
06:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-07-2021
06:11 AM
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
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