Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Macro returns iProperty of part's OAL

cadman777
Advisor

Macro returns iProperty of part's OAL

cadman777
Advisor
Advisor

Hi all,

Does anybody have a macro that does the below function?
I tried a couple macros I picked off this forum, modified them a bit, and they failed under all but one circumstance.

So nothing so far has helped me.

Here's the Macro Function that I need:

FIND THE OVERALL LENGTH OF A PART PERPENDICULAR TO THE PART'S PROFILE, AND SEND IT TO AN iPROPERTY IN THE PARAMETERS.

The macro that I like the best from this forum does exactly that ONLY with out-of-the-box CC parts.

But as soon as I modify a CC part by changing the profile plane, the macro quits working.

So it's very limited, and now Inventor is forcing me to return to my old method of using work features + a sketch. Needless to say, that's a MEGA waste of time and energy for a function that SHOULD BE a native to the software.

Anybody have anything like that they wanna share w/me?

TIA ...

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Reply
799 Views
9 Replies
Replies (9)

cadman777
Advisor
Advisor

Anybody have any input on this?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes

marcin_otręba
Advisor
Advisor

Hi,

i see here lack of information about your need, especially when it comes to your designs and modelling practices. It can be very tricky if models are messed up. I would start from determining first feature sketch orientation and depending from feature type i could get direction what i need, then it is only to use rangebox from that direction.

Maybe start from shearing some content ? also the macro what you wrote about.

0 Likes

cadman777
Advisor
Advisor

Marcin,

Thanx for your reply.

More info:

All parts are straight extrusions (pipes, beams, flat bars, etc.)

I want over-all-length (OAL) after all cuts and other features on the part.

OAL is perpendicular to profile sketch plane OR parallel to direction of extrusion (sometimes the profile is at an angle to the extrusion).

End treatments may or may not change the length of the original extrusion.

Profile sketch is first sketch in model browser.

Extrusion is first feature in model browser.

I want to pass that OAL dimension to an iProperty that exists in the Parameters ("G_LL" in my parts).

Some parts are simple extrusions that have no other features than the extrusion itself.

Other parts are the extrusion plus end treatments, such as chamfers, miter cuts, double and triple miter cuts, compound miter cuts, holes, copes, etc. The extrusion can have any kind of feature on it plus end treatments. One of the most used is coped pipe on handrail. The cope is perpendicular to the surface of the extrusion.

I want this to work everywhere in Inventor, custom parts, FrameGenerator, CC parts, etc.

Is this enough info?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes

marcin_otręba
Advisor
Advisor
0 Likes

cadman777
Advisor
Advisor

Thanx for the link.

Looks interesting, but nothing promising.

 

This is what I got out of it, from my perspective/experience:

There are at least 2 kinds of parts that will be problematic for determining OAL, OAW and OAT:

1. Plates

2. non-Plates

 

So the first thing I'd do, IF I could code, is separate between Plates and non-Plate parts.

Then I'd separate the non-Plate parts into Standard CC type shapes/extrusions and non-Standard parts (like purchase items, such as bolts, hinges, valves, etc.)

Once the part type is identified, then there would be 1 of 2 codes to run to get the correct dimensions.

One code would apply to Plates, and the other code would apply to non-Plate parts that are strictly Straight extrusions.

 

The plates would be easy, since you can FlatPattern them and make sure the longest edge is bottom & horizontal.

The non-Plates would be easy too, b/c you could work from the extrusion direction or plane which the extrusion sketch is on. You just go to either side of that sketch plane till you don't find anything to measure, then add up the results algebraically.

 

Otherwise, I have no idea how to write that code, no skill on doing it, and no clue where to begin.

 

Let me add: If I wanted to start A NEW CAREER IN CODING I would do it, b/c that's what this requires.

And IF I did that, after all that WORK, I BET I'd discover that VBA can't do what I need (big bummer!).

In any case, from my experience, I believe that I don't have the 'wiring upstairs' any longer to be a coder.

NOT EVERYBODY CAN WRITE CODE.

I say that for the benefit of some people in here (not you).

 

So thanx for the link, but that doesn't get me even 1 micron closer to where I need to be.

Cheers 

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes

DRoam
Mentor
Mentor

Hi @cadman777, if you have Inventor 2020 or later, there's a new function that finds the minimum bounding box for non-orthogonal (not parallel to the origin) parts. It sounds like it may be useful in your situation? If you have 2020 or later, give the code below a try on some of your parts that are giving you problems.

 

' Get the current Part document.
Dim partDoc As PartDocument = ThisDoc.Document

' Get surface body to measure (assume it's the first body).
Dim body1 As SurfaceBody = partDoc.ComponentDefinition.SurfaceBodies.Item(1)

' Check Inventor version. Must have Inventor 2020.3 (24.3) or later to use "OrientedMinimumRangeBox".
Dim version As SoftwareVersion = ThisApplication.SoftwareVersion

If version.Major < 24 OrElse (version.Major = 24 AndAlso version.Minor < 3) Then
	MessageBox.Show("Must have Inventor 2020.3 or later installed to use this feature.", "Oriented Minimum Rangebox", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
	Exit Sub
End If

' Get the oriented mininum range box of the body.
Dim minBox As OrientedBox = body1.OrientedMinimumRangeBox

' Get length of each side of mininum range box.
Dim dir1 As Double = minBox.DirectionOne.Length
Dim dir2 As Double = minBox.DirectionTwo.Length
Dim dir3 As Double = minBox.DirectionThree.Length

' Convert lengths to document's length units.
Dim uom As UnitsOfMeasure = partDoc.UnitsOfMeasure

dir1 = uom.ConvertUnits(dir1, "cm", uom.LengthUnits)
dir2 = uom.ConvertUnits(dir2, "cm", uom.LengthUnits)
dir3 = uom.ConvertUnits(dir3, "cm", uom.LengthUnits)

' Sort lengths from smallest to largest.
Dim lengths As New List(Of Double) From {dir1, dir2, dir3 }
lengths.Sort

Dim minLength As Double = lengths(0)
Dim midLength As Double = lengths(1)
Dim maxLength As Double = lengths(2)

' Display minimum rangebox size.
MessageBox.Show("Oriented Minimum Rangebox Size: " &
	minLength.ToString("#.####") & " x " & midLength.ToString("#.####") & " x " & maxLength.ToString("#.####"),
	"Oriented Minimum Rangebox", MessageBoxButtons.OK, MessageBoxIcon.Information)

 

Note that if you have 2020, you'll need to install the 2020.3 update for it to work. I added some code to demonstrate how you can check to make sure whoever's running the code has the required version/update.

0 Likes

cadman777
Advisor
Advisor

DRoam,

Minimum bounding box" does not sound like it's of any use in this scenario.
It sounds like another Autodesk trinket to keep the natives from revolting.

Anyways, thanx for this code!

Unfortunately, I have 2010!!

So am I correct in saying that Autodesk has NOT provided this software function for Inventor UNTIL THIS YEAR?

And, it is basically IMPOSSIBLE to accomplish this task w/code on any earlier year of Inventor?
Cheers ...

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes

DRoam
Mentor
Mentor

Hi Chirs, it's certainly not a trinket, it's a very powerful tool that will be very useful for many people (including myself) and many workflows. I suspect it may be helpful for yours, but I'm not sure. I would need to see one of your parts to say for sure.

 

Correct, it was implemented in Inventor 2020 so it will not be available in previous versions. However, it's not the only way to measure non-orthogonal parts. It's certainly not impossible to do so using APIs from Inventor 2010. Just will require a different approach.

 

It would help a lot if you could attach an example of one of your parts that are not working with the code you currently have. That would make it much easier to help you find a solution.

0 Likes

cadman777
Advisor
Advisor

Thanx DRoam.

I'll attach one soon as I got a moment.

Been real busy chasing my tail on these sorts of things that eat up the clock.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes