Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Measure length of a named edge

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
nicolas.oeillet
232 Views, 4 Replies

Measure length of a named edge

Hi everyone,

I have an edge names "A_pince_AR" in a part.

I want to measure the length of this edge to save it into a parameter.

But I can't find how to measure the length of an edge with ilogic.

Can someone help me ?

Thanks

 

Tags (3)
4 REPLIES 4
Message 2 of 5

Hi @nicolas.oeillet . This code gets the length of your edge and displays a message (line 13), edit line 12 to write the length into your parameter.

Dim oDoc As PartDocument = ThisDoc.Document
Dim oUOfM As UnitsOfMeasure = oDoc.UnitsOfMeasure
Dim iLogicAuto = iLogicVb.Automation
Dim oNamedEntities As NamedEntities = iLogicAuto.GetNamedEntities(oDoc)
Dim oEdge As Edge = oNamedEntities.FindEntity("A_pince_AR")
Dim oCurveEval As CurveEvaluator = oEdge.Evaluator
Dim MinParam As Double
Dim MaxParam As Double
Dim Length As Double
oCurveEval.GetParamExtents(MinParam, MaxParam)
oCurveEval.GetLengthAtParam(MinParam, MaxParam, Length)
'NameYourParam = Length
MessageBox.Show(oUOfM.ConvertUnits(Length, UnitsTypeEnum.kCentimeterLengthUnits, oUOfM.LengthUnits), "Title")

 

Andrii Humeniuk - Leading design engineer

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 5

Thank you so much

Message 4 of 5

Hi @nicolas.oeillet 

 

Just in case you or someone in the future is needing to do this from an assembly, here is an example that uses Andrii_Humeniuk example.

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oOcc As ComponentOccurrence
Dim oEdgeProxy As EdgeProxy
edgeName = "A_pince_AR"

Dim oUOfM As UnitsOfMeasure = oDoc.UnitsOfMeasure
Dim sUOfM = oUOfM.GetStringFromType(UnitsTypeEnum.kDefaultDisplayLengthUnits)
Dim MinParam As Double
Dim MaxParam As Double
Dim Length As Double

For Each oOcc In oDoc.ComponentDefinition.Occurrences
	Dim oNamedEntities = iLogicVb.Automation.GetNamedEntities(oOcc.Definition.Document)
	If oNamedEntities.NameExists(edgeName) = False Then Continue For
	Dim oEdge As Edge = oNamedEntities.FindEntity(edgeName)
	oOcc.CreateGeometryProxy(oEdge, oEdgeProxy)

	Dim oCurveEval As CurveEvaluator = oEdge.Evaluator
	oCurveEval.GetParamExtents(MinParam, MaxParam)
	oCurveEval.GetLengthAtParam(MinParam, MaxParam, Length)	
	oValue = Round(oUOfM.ConvertUnits(Length, UnitsTypeEnum.kCentimeterLengthUnits, oUOfM.LengthUnits),3)
	'NameYourParam = oValue
	MessageBox.Show(oValue & " " & sUOfM, "Title")
Next
Message 5 of 5

How can I modify line 12 to put it in the parameter?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report