In iLogic I can access the length of an extrusion created using "Distance" with this code:
Dim oExtr As ExtrudeFeature = oFeatures.Item(1)
oExtr.Definition.Extent.Distance.Value
How would I get the length of an extrusion created using "Between"?
Steve
Without more info as to what you are extruding between I offer the following...
If the extrusion is between 2 parallel planes or faces (normal to the extrusion) this may work, otherwise a different approach may be needed. Convert units as needed.
'Assume Inventor is open
'Assume a part document is active 'Assume the first extrude feature in active part document is defined between faces
'Assume InventorApp is your current inventor session
Dim InventorApp as Inventor.Application = Marshal.GetActiveObject("Inventor.Application") Dim PrtDoc As PartDocument = InventorApp.ActiveDocument Dim CompDef1 As PartComponentDefinition = PrtDoc.ComponentDefinition Dim Obj1 As Object Dim Obj2 As Object Obj1 = (CompDef1.Features.ExtrudeFeatures.Item(1).Extent.ToFace) 'Get the first face Obj2 = (CompDef1.Features.ExtrudeFeatures.Item(1).Extent.FromFace) 'Get the second face MsgBox(InventorApp.MeasureTools.GetMinimumDistance(Obj1, Obj2)) 'Return distance between faces in centimeters
What approach is needed when you extrude from plane to cylinder or cone?
Or would this also work in this case? Haven't got the time try it out, will give it a shot tomorrow.
The problem with the "between" distance, is that it might not be constant. If you extrude between two planes that are not paralell, your extrusion is not regular (one side of the extrusion will be shorter then the other side). See my attached image as an example. In my case, I extruded between a plane offset from my sketch plane and an other on that is at 45 degrees from my sketch.
In my case, as pointed out by CAD_CAM_MAN, his code will output a distance of zero since my planes are intersecting somewhere. What you might do is to use the RangeBox of the feature to find the size. Here's a small exemple where my extursion is based on a sketch on XY plane, so the extrusion is along the Z axe (the same as on the attached image). Using the RangeBox, I substract the minimum point from the maximum to obtain the difference. If your extrusion is not along an axe, your highschool trigonometry classes might become handy...
Dim doc as PartDocument = ThisDoc.Document Dim CompDef As PartComponentDefinition = doc.ComponentDefinition Dim MinZ As Double = CompDef.Features.ExtrudeFeatures.Item(1).RangeBox.MinPoint.Z Dim MaxZ As Double = CompDef.Features.ExtrudeFeatures.Item(1).RangeBox.MaxPoint.Z MessageBox.Show("Z size is : " + CStr(MaxZ - MinZ),"Distance")
This is very rough code and it does not do any validation, but in my particular case it's giving me the overall height of my extrusion. Juste remember the dimensions given by code is always centimeters, you might want to convert...
Hope this will help.
The maximum distance is the one i'm looking for 🙂