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: 

iLogic to get Length of "Extrude Between"

6 REPLIES 6
Reply
Message 1 of 7
ad64
1111 Views, 6 Replies

iLogic to get Length of "Extrude Between"

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

 

 

 

6 REPLIES 6
Message 2 of 7
ad64
in reply to: ad64

I'm still looking for an answer on this. Are there any takers?

 

Steve

Message 3 of 7
CAD_CAM_MAN
in reply to: ad64

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
Message 4 of 7
Jef_E
in reply to: CAD_CAM_MAN

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.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 5 of 7
CAD_CAM_MAN
in reply to: ad64

I don't think it will work as above to a cylinder or cone. If extruding to a cone or cylinder what length are you looking for, minimum distance or..?
Message 6 of 7
pberube
in reply to: CAD_CAM_MAN

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.

 

 

Pierre Berube
Autodesk Certified Professional - Inventor 2015
Message 7 of 7
Jef_E
in reply to: CAD_CAM_MAN

The maximum distance is the one i'm looking for 🙂



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2

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

Post to forums  

Autodesk Design & Make Report