Message 1 of 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
is it possible create iLogic for add chamfer to all edge on selected body?
Solved! Go to Solution.
Hi,
is it possible create iLogic for add chamfer to all edge on selected body?
Solved! Go to Solution.
This is the easiest way. This code adds chamfer to all edges, but be careful because you can't run it twice on body or it fails when the chamfer on some edge can't be created.
Sub Main
Dim part As PartDocument = ThisDoc.Document
Dim body As SurfaceBody = part.ComponentDefinition.SurfaceBodies(1)
Dim distance As Double = 0.05
Dim edges As EdgeCollection = ThisApplication.TransientObjects.CreateEdgeCollection()
For Each edge As Edge In body.Edges
edges.Add(Edge)
Next
part.ComponentDefinition.Features.ChamferFeatures.AddUsingDistance(edges, distance)
End Sub
Thanks,
I work with multibody part. Is it possible, when I run rule, that I need select body for chamfer and field for chamfer value?
Yes, you can use Pick Method for selecting body and InputBox for input distance value.
Sub Main
Dim part As PartDocument = ThisDoc.Document
Dim body As SurfaceBody = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select part") ' part.ComponentDefinition.SurfaceBodies(1)
Dim distance As Double = Double.Parse(InputBox("Chamfer distance", "iLogic", 0.05)) ' 0.05
Dim edges As EdgeCollection = ThisApplication.TransientObjects.CreateEdgeCollection()
For Each edge As Edge In body.Edges
edges.Add(Edge)
Next
part.ComponentDefinition.Features.ChamferFeatures.AddUsingDistance(edges, distance)
End Sub
Perfect,
but I think that iLogic have minor bug. If I want chamfer 2, in field must be 0,2
Hi @kresh.bell,
Inventor internaly uses centimeters. If you create a double with a value of 1, it will read 1cm what ever the document unit is. If you want your distance to be 1mm, you'll need to convert it by dividing the input value by 10 :
Dim distance As Double = (Double.Parse(InputBox("Chamfer distance", "iLogic", 0.05))) /10 ' 0.05
Kind regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"This is because Inventor's internal units are [cm]. You need to convert input string to appropriate numeric value in required units.
Is it big problem add option multibody select?
@kresh.bell,
I'm not sure to understand correctly your request ? What would be the workflow?
To be able to select one or more solid bodies by click?
Kind regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"yes
Hi @kresh.bell,
Note you can mark multiple replies as solutions for your topic. Here is a code that let you pick multiples surfacebodies. When you are done selecting, simply press "esc" to create the chamfers :
Sub Main
Dim doc As Inventor.PartDocument = ThisApplication.ActiveDocument
Dim partdef As Inventor.PartComponentDefinition = doc.ComponentDefinition
Dim bodyCol As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For i As Integer = 1 To partdef.SurfaceBodies.Count
Dim body As SurfaceBody = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select part")
If body Is Nothing Then Exit For
If check(body, bodyCol) = False Then bodyCol.Add(body)
Next
Dim distance As Double = (Double.Parse(InputBox("Chamfer distance", "iLogic", 0.05))) / 10 ' 0.05
Dim edges As EdgeCollection = ThisApplication.TransientObjects.CreateEdgeCollection()
For Each body As Inventor.SurfaceBody In bodyCol
For Each edge As Edge In body.Edges
edges.Add(Edge)
Next
Next
partdef.Features.ChamferFeatures.AddUsingDistance(Edges, distance)
End Sub
Private Function check(input As Object, col As Inventor.ObjectCollection)
If col.Count = 0 Then Return False
For Each obj As Object In col
If obj is input Then Return True
Next
Return False
End Function
Does this suits your needs ?
Kind regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"Perfect, thanks
iLogic works perfect. Is it possible, when I select bodies, that selected bodies be highlights