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: 

Get lenght of a chamfer

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
frank_schalla
455 Views, 3 Replies

Get lenght of a chamfer

Hmmm i dont find a way to get the lenght of a chamfer (selected edge) over the API.

Anyone has a idea ??

 

3 REPLIES 3
Message 2 of 4
JelteDeJong
in reply to: frank_schalla

try this iLogic code:

Dim f As PartFeature = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFeatureFilter, "Select champfer")
If (TypeOf f Is CornerChamferFeature) Then ' for sheetmetal parts
	MsgBox(f.Definition.ChamferDefinition.Distance.Value * 10) 
Else If (TypeOf f Is ChamferFeature) Then ' for parts
	MsgBox(f.Definition.Distance.Value * 10)
Else
	MsgBox("None champfer selected")
End If

this does not work if the champfer option 2 distaces is chosen. in that case you could use:

  • f.Definition.DistanceOne.Value
  • f.Definition.DistanceTwo.Value

and calculate the distance your self.

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 4
JhoelForshav
in reply to: JelteDeJong

Hi,

I think what @frank_schalla is looking for is the length of the chamfered edge, Not the length parameter of the chamfer feature...

If so, maybe something like this should do the trick?

Sub Main
Dim oDoc As PartDocument = ThisDoc.Document
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oChamfs As ChamferFeatures = oDef.Features.ChamferFeatures
Dim oChamf As ChamferFeature = oChamfs.Item(1)
oChamf.SetEndOfPart(True)
Dim totLength As Double = 0
For Each oEdge As Edge In oChamf.Definition.ChamferedEdges
	
	totLength += EdgeLength(oEdge)
Next
oChamf.SetEndOfPart(False)
MsgBox(totLength)
End Sub
Function EdgeLength(ByRef oEdge As Edge) As Double
   
    Dim curveEval As CurveEvaluator
     curveEval = oEdge.Evaluator
    Dim minParam As Double
    Dim maxParam As Double
    Call curveEval.GetParamExtents(minParam, maxParam)
    Dim curveLength As Double
    Call curveEval.GetLengthAtParam(minParam, maxParam, curveLength)
    
    EdgeLength = curveLength * 10
End Function

 For this example i simply took the chamferfeature item 1 in the model. But you can of course use it on a selected chamfer feature as well 🙂

Message 4 of 4

Hello Jhoel Forshav 

thank's you both and yes you are right.

The chamfer values was easy but based on you idea also the edges now we can grab

Thank You 🙂

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

Post to forums  

Autodesk Design & Make Report