how do I get Curve Loop Lenght into ilogic?

how do I get Curve Loop Lenght into ilogic?

Darkforce_the_ilogic_guy
Advisor Advisor
1,270 Views
2 Replies
Message 1 of 3

how do I get Curve Loop Lenght into ilogic?

Darkforce_the_ilogic_guy
Advisor
Advisor

How do I get the Curve Loop length in ilogoc? I have an profil that alway have 2 feature and 2 Sketch? they are alway call the same .. What I need is the Sketch call "Tooth Belt path"  Curve loop length of the sketch.

 

Is that a way to do this ? 

Accepted solutions (2)
1,271 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

For example see the attached part

'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
MsgBox(String.Format("Length of non-construction entities is {0:N2} [cm]", loopLength))
Message 3 of 3

Darkforce_the_ilogic_guy
Advisor
Advisor
Accepted solution

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

 

 

 

0 Likes