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
Solved! Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
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.
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