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 Formual

28 REPLIES 28
Reply
Message 1 of 29
andrew.warren
2063 Views, 28 Replies

iLogic Formual

I am trying to create a iLogic Rule that will measure the Length, Width and Thickness of a part and ut it into the custom fields we have. I am having a hard time rememebring how to get it to do it from the assembly level. I want to run this on the assembly and have it populate all the parts inside of it. The code below will do it for a part but what is it I add to get it to drill down into the assembly?

 

iProperties.Value("Custom", "THICKNESS")=Measure.ExtentsHeight

iProperties.Value("Custom", "WIDTH")=Measure.ExtentsWidth

iProperties.Value("Custom", "LENGTH")=Measure.ExtentsLength

 

Then I want ti to add this formyual to the Stock Number iProperty = <Length> X <Width>   I can get it to add the values but I can not get it to add the formual to the stock number.

 

I have 10,000 things to do and I can not concentrate long enough to figure this one out. Any help would be apprciated!

Andy Warren
BCDesign@bellsouth.net
28 REPLIES 28
Message 21 of 29
Q-Bixx
in reply to: andrew.warren

Nobody has a solution? Robot Sad

Message 22 of 29
mehatfie
in reply to: Q-Bixx

Hi Q-Bixx,

 

I'm not involved with this conversation, but took a quick look at your post.

 

My best guess is that your rule is taken the X and Y components of the line while taking its measurements.

 

For example, I have a line that's not parallel to either the X or Y axis.... technically, this is now the hypotenuse of a triangle with component relations to the X and Y axis.

 

I believe your rule is taking the X component of your diagonal 50 line, and this is where the 47.54 may be coming from.

 

Again, I'm not up to date on what conversation has been going on, but this would be my best guess while looking at your last post.

 

 

Regards

Mitch

 

Let me know if it helps... Kudos if it works!!!

Message 23 of 29
Q-Bixx
in reply to: Q-Bixx

You got the point. 🙂

That exactly what i meant with this 'solution', it's only a solution for 80% of the time.

It's not only based on a X-Y component, but also the Z (Your part could be designed in the base component as inclined for example)

Perhaps this could be a solution would be that you could indicate a first surface, and a second one, just to calculate the surfaces.

And by those equasions calculate the width, length an height of the Bounding Box.

 

But then here you would be facing another problem that is if your inclined piece is not only rectangular, but rectangular with (fe: chamfers or fillets or with a hole or ...). You get different values of a bounding box.

 

Perhaps i should explain why i could need this tool.

It would be handy to get in my description a raw material dimension (such as the bounding box) and by that bounding box have Inventor tell me whether i need to make a detail drawing or not.

If the Theorethical Weight (the one calculated from the bounding box) is equal to the Physical Weight, then i wouldn't need to make a detailed drawing, for any other situation i should.

But then i'm trying to avoid the problem with inclined bodies ... cause it gives a different bounding box value, thus the weight is different, thus a drawing should been made (while it could be a flat bar beeing inclined)

 

Come on you geniouses over here!

Help me ;)))

 

Message 24 of 29
xiaodong_liang
in reply to: Q-Bixx

Hi,

 

I'm not either up to date on what conversation has been going on. It looks you descibed the problem in message 20, right? Could you provide a demo of  the rule you are using? I can try to take a look what's problematic. 

Message 25 of 29
kmiller
in reply to: Q-Bixx

Anyone ever find a solution to the above issue regarding the extents not displaying how desired when a piece is rotated?  It's something I think we could use a bunch here but I haven't figured it out either.  Honestly, I would like to know if there is a way to do this by just selecting on a particular drawing view.  It's the only "starter' way I can think of for us, as we have to rotate and orient the piece as desired on such a view. 

 

So if anyone has any ideas I am up for discussion.

-------------------------------------------------------------------------------------------------

If this response answers your question please click "Accept as Solution".
Message 26 of 29
pcrawley
in reply to: kmiller

I've been watching his post evolve into something quite different from the OP.

 

Is the new question "Can you find the Length, Width and Thickness of a box that is rotated from the origin planes?"  Assuming the box object is a part-file in an assembly, or a body in a multi-body solid, the answer is yes,  you can find these values.  (By "box" I mean an extruded rectangle shape where all the faces are at 90 degrees to eachother.)  There is something in the API that finds the bounding-box shape, but that shape is based on the orientation of the origin planes, so it's no use when a part is rotated about one (or more) axis.

 

The API does however gives you access to the edges of all bodies (parts/solids/surfaces) and their start/stop vertices.  From the coordinates of these vertices you can quickly calculate the length of each edge.  If you then sort those twelve edge lengths, the smallest four will be the smallest dimension of the box (say "Thickness").  The middle 4 lengths will be the "Width", and the longest 4 will be the "Length".

 

If I've got the question wrong (or this post is too old), someone tell me to go post elsewhere 😉

Peter
Message 27 of 29
yannick3
in reply to: pcrawley

Hi

Maybe you can not find the real dimension automaticly but with the measure tool and ilogic, my coworker have scripted a rule and  when we run the rule we answer to ilogic questions and depending on what we answered the measure tool come active and we find on graphic window what face or points or circle we want measuring and automaticly the bounding box is calculated, but it's not associative......... he works on that now

 

I think the trick is the ability to create an associative parametre with the measure tool, for the oldtimer forum i remember Sean Dotson have scripted a add-in who make that but i can't find anything on the new mcad forum, this was for Inventor 11 or 2008 maybe 2009

Yannick Verreault
INV PRO 2015
MS Office 2007
Win 7 pro, core i7 950, asus P6T WS
nvidia Gforce GTX 295
WD caviar black 500Go
WD caviar black 1To

Message 28 of 29
MechMachineMan
in reply to: yannick3

Suggestions to make this macro/sub more robust:

 

1. Find the sizes of the part by EXPLICITLY calling the ComponentDefintion.RangeBox feature. From there, the math can be done to find the respective differential lengths (*note, rangebox will include VISIBLE work features/axes/planes/points, so they must be HIDDEN first).

 

2. Put the values into a list as double values and sort that list (as it will sort in order from smallest to largest or vice versa) OR write the 6 or so lines of code it takes to compare the values to eachother to find what the smallest and largest values are.

 

 

Other notes: iLogic is cool and quick, but as soon as you try and take it out of the application of using it in the file it is run in, it seems toget a little buggy and hard to predict. It's not too tough or much longer for programming to make the program explicit. There are also much better, more thorough resources that explain and have samples for how to prorgram explicitly; ie:

 

"C:\Program Files\Autodesk\Inventor 2016\Local Help\admapi_20_0.chm"


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 29 of 29
woodshopcg
in reply to: andrew.warren

I'm trying to get a similar code to work " set the length , width, " iproperties in each part of an assembly. did you ever get your to work?

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

Post to forums  

Autodesk Design & Make Report