Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Darkforce_the_ilogic_guy
188 Views, 0 Replies

Total Lenght of 2d and 3d sketch, Possible?

 

I have this code that can add all lenght of 2d sketch  into a total length. this code does not work with a 3d skecth, can I make a code that work with 3d sketch ? I want to make an content center part for hoses, but I need  the total lenght as a properties G_L for our ERP system

 


Try
	'Find content center family  name
	oDoc =ThisDoc.Document
Dim family = oDoc.PropertySets("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")("Family").Value


If family = "Timing belt" Then 
'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
End If 
Catch
	
End Try

 

 

Tags (1)