'pyautocad object iteration finds every second objects
When I run my script It find every second text object and modifies after it also re iterate aready modified objects. how to set strait?
according to the picture red ones are skipped ones, blue ones itterated second time

from pyautocad import Autocad, APoint
import re
acad = Autocad()
pattern = re.compile("([0-9]+)\+([0-9]+)\.([0-9]+)") # Example 37+45.63
addValue = 51 # Value To add a Chainage 0.51m
for text in acad.iter_objects('Text',limit = None):
if pattern.search(text.TextString): #Check only Texts where patter has been found
textContent = text.TextString # Get full Text content for reuse
getCoord = text.InsertionPoint #Get Existing Text Coordinates
coord = APoint(getCoord) #Set Coordinate for new Text
rotation = text.Rotation # Get existing Text Rotation
height = text.Height # Get existing Text Height
finded = pattern.search(textContent)# Finded Pattern Text
a = int(finded.group(1)) # Regex Group 1 example (37)+45.63
b = int(finded.group(2)) # Regex Group 2 example 37+(45).63
c = int(finded.group(3)) # Regex Group 3 example 37+45.(63)
###################################################
sum1 = c + addValue #######
if sum1 >= 100: #######
c = sum1 - 100 #######
b += 1 #######
if b + 1 >= 100: ####### This section must be
a += 1 ####### A seperate Function But
b -= 100 ####### I did not manage
else: #######
c = sum1 #######
########################################################
modStr = pattern.sub(f'{a}+{b}.{c}', textContent) # Modified Text To be Placed
text.Delete() #Delete text to reinsert
newText = acad.model.AddText(modStr, coord, height) #Create New text objects in the model
newText.rotation = rotation # Add same rotations as source before deleting
print("Done!")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
