I change the code a lillte , now I just need to find a way to make it only run in the right content center part. but this part of the code seems to work
'Get sketch with loop
Dim oSketch As Sketch = ThisDoc.Document.ComponentDefinition.Sketches("Tooth Belt path")
Dim loopLength As Double = 0
'Iterate all sketch entities
For Each entity As SketchEntity In oSketch.SketchEntities
'Skip construction entities
If entity.Construction Then Continue For
Try
'Get entity length when possible
Dim entityLength As Double
entityLength = entity.Length
'Add entity length to loop length
loopLength = loopLength + entityLength
Catch
'Ignore entities without length
'For eaxample SketchPoint hasn't length
Continue For
End Try
Next
'Use result in mm
Parameter("G_L") = loopLength * 10