auto extract of a reference length

auto extract of a reference length

Anonymous
Not applicable
915 Views
7 Replies
Message 1 of 8

auto extract of a reference length

Anonymous
Not applicable

hi,

 

i always have to do these for every part and i wonder if i can automate it . i have a background in programming but very very basic and would love to learn api or macros, if ijust know know where to go to.

 

anyway, this is what ive been doing.

 

after creating a solid and made some cutting, notching etc. the finished length is not the same as the initial extruded solid. so to get the length of the final solid ,

1. i would project geometry , and get the extreme end to get the finish length,this reference dim is now shown in parameter,

2.go to parameter and change this ref dim name to "length" , 

3.check the export box ,

4. right click this ref dim to change the custom property format

5.where i would uncheck the "units string" box

 

all these steps to extract the length of a single part , so just imagine if my assembly consist of 50 parts, i would do this 50 times! and usually i have almost a hundred assembly to work everytime. please help!!

 

 

 

thanks a lot

inventor 2011

vault pro 2012

 

 

0 Likes
Accepted solutions (1)
916 Views
7 Replies
Replies (7)
Message 2 of 8

jtylerbc
Mentor
Mentor

Look into iLogic.  Specifically, the Measure.Extents.  These will let you programmatically measure the extents of the part in the X, Y, and Z directions and write them to iProperties or user parameters, without the need to create sketches at all.

 

The iLogic rule is then stored in the part template (a special one, if necessary), so you don't have to recreate anything each time.  It's already there.

 

I have recently finished creating a rule that uses this method to measure the overall dimensions for plates used in steel fabrication.  So far it's proven to be much more reliable (and a LOT easier to use) than our previous method, which used sketches similar to your description.

 

I didn't have much of a background in programming at all before starting to work with iLogic.  I found it to be pretty easy to pick up, so you should have an even easier time.

0 Likes
Message 3 of 8

Anonymous
Not applicable
I havent done any ilogic. Would you mind sharing yours? Pleassssssseeeee...

Thanks for replying ...
0 Likes
Message 4 of 8

jtylerbc
Mentor
Mentor

I don't mind sharing it, but had skipped doing so before because it's very specifically tailored to what we're using it for.

 

Before you dig too deeply into the code - are these models you are creating yourself, or are they Frame Generator structural shapes?  This code can technically be made to work in either case, but if you're working with Frame Generator, there's an easier way that doesn't involve code at all.

 

Below is my code.  It is intended for use in steel plate fabrication work.  The comments throughout the code should explain most of what it's doing.  Essentially, it does the following:

 

  1. Makes sure the part is updated before doing any of the measurements
  2. Turns off the Object Visibility of all work features (work planes, points, axes) so they will not be included
  3. Measures the extents of the plate in X, Y, and Z directions.
  4. Sorts these to determine which is the Thickness, Width, and Length of the plate.
  5. Assigns the values to an appropriate User Parameter
  6. Turns the Object Visibility back on

 

 

' This rule uses the Measured Extents in the X, Y, and Z directions to develop parameters which will be used in the plate's
' material list description.

oDoc = ThisDoc.Document
Dim WorkFeatureVisList As New ArrayList

' Verify that the document is fully updated prior to taking measurements.
InventorVb.DocumentUpdate()

' Work features will be included in the extents if they are visible, which interferes with accurate measurement of the plate.
' Object visibility of work features and surfaces will be set to invisible before the measurements are taken, then returned to their previous state.

'toggle construction surface visibility off
oDoc.ObjectVisibility.AllWorkFeatures = False
oDoc.ObjectVisibility.ConstructionSurfaces = False
oDoc.ObjectVisibility.Sketches = False
oDoc.ObjectVisibility.Sketches3D = False


' Determine the extents of the part in X, Y, and Z directions
X_Measure = Measure.ExtentsLength
Y_Measure = Measure.ExtentsWidth
Z_Measure = Measure.ExtentsHeight


' Create an array from the measured values
Measured_Extents = New Double(){X_Measure,Y_Measure,Z_Measure}

' Sort the array in ascending order
Measured_Extents.Sort(Measured_Extents)


' Assign the measured values to the appropriate parameter based on their sorted order
THK = Measured_Extents(0)
WIDTH_DESC = Measured_Extents(1)
LENGTH_DESC = Measured_Extents(2)


'toggle construction surface visibility on
oDoc.ObjectVisibility.AllWorkFeatures = True
oDoc.ObjectVisibility.ConstructionSurfaces = True
oDoc.ObjectVisibility.Sketches = True
oDoc.ObjectVisibility.Sketches3D = True

' Update so changes are visible to the user
iLogicVb.UpdateWhenDone = True

 

 

The User Parameters are then marked for Export and embedded in the Description iProperty, just as you were doing with your reference length dimension. 

 

In your case, if your parts are always modeled in the same orientation, you might be able to take out the "Array" portions of the code, and only measure in that direction.  If that's not the case, then you might be able to use the array to find the largest of the three measurements, and then use that as your "Length" parameter.

0 Likes
Message 5 of 8

Anonymous
Not applicable

hi

 

im not using frame gen, i use multibody then make part.

i tried your code but it doesnt write the dim to the parameter.

im looking for the command that will write it to the parameter but cant find it.

 

inventor 2011

vault pro 2012

0 Likes
Message 6 of 8

jtylerbc
Mentor
Mentor

Make sure you create the parameters (manually) in the Parameters dialog box.  The way my code is written, it won't write the values to the parameters if they don't already exist.  I didn't include anything in my code to create missing parameters, as they already exist in the template files that this rule was originally written for.

 

You'll need to create user parameters named:

 

THK

WIDTH_DESC

LENGTH_DESC

 

After you add them, you may need to right-click on the rule in the iLogic browser and pick Regenerate Rule.  After that it should work.

0 Likes
Message 7 of 8

Anonymous
Not applicable
Accepted solution

oh my god! it works...!!!!

i just have to change it a bit to suit us.

 

i tried it from a derived solid from other part, it also works. thanks a lot!!!

 

i still have some question,

 

where can i see all these methods/classes (eg. ObjectVsibility.AllWorkFeatures)

thanks you so much!!!!!!!:Smiley Happy

0 Likes
Message 8 of 8

jtylerbc
Mentor
Mentor

There isn't much help available from within iLogic.  Fortunately, you can use the various forms of help from the VBA editor (Object browser, etc), as iLogic uses the same object model as the normal Inventor API.  There is also a giant PDF chart of the object model that was installed on your machine with Inventor, which should be available in the following folder:

 

C:\Users\Public\Documents\Autodesk\Inventor 2013\SDK\DeveloperTools\Docs

 

Unless it's already been done, you will need to run the SDK installer first, located here:

 

C:\Program Files\Autodesk\Inventor 2013\SDK

 

There is also a lot of sample code for both VBA and iLogic floating around on these forums, and plenty of people here who are willing to help (many of which know a lot more than I do about the programming side).

0 Likes