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: 

Calculate Limits Max and Min Assemblies Files

4 REPLIES 4
Reply
Message 1 of 5
Crstiano
1495 Views, 4 Replies

Calculate Limits Max and Min Assemblies Files

I need a new way to measure the limits of assembly, because when I use rangebox I find a problem, the Inventor calculates the box for parts, thus creating maximum and minimum values of the different correct.

 

The limit X=499mm

limitX.png

 

With Rangebox (similar checkdesign) The limit X = 533,32mm 

Box.pngparalelo.png

Cristiano Oliveira
Developer Addins | Consultant CAD/PLM | CAD Manager
https://www.ConsultCAD.com/


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Tags (2)
4 REPLIES 4
Message 2 of 5
Vladimir.Ananyev
in reply to: Crstiano

The component definition object owns the model, sketches, work geometry, etc.  So all of those should to be part of the range box returned. 

If this is your case then you can get a range box from a SurfaceBody object.  If there’s more than one body you may need to get the range from each one and then combine them.

Similar problem was discussed here:

http://forums.autodesk.com/t5/Inventor-Customization/RangeBox-error-Adding-plan-sizes-to-the-dimensi...


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 5
Crstiano
in reply to: Vladimir.Ananyev

Hi Vladimir,

Follow example attached.

I already use this feature to disable the work features, follow the macro.iLogic.

 

In my case, is assembly with parts and some parts are positioned in angles creating box.

 

Dim odoc As AssemblyDocument
odoc = ThisApplication.ActiveDocument
 
'Get the All Workfeatures" command
Dim oCtrlDef As ButtonDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppAllWorkfeaturesCmd")
If oCtrlDef.PRESSED Then
oCtrlDef.Execute
End If
 
Dim vX, vXmax, vXmin As Double
vXmax = odoc.ComponentDefinition.RangeBox.MaxPoint.X
vXmin = odoc.ComponentDefinition.RangeBox.MinPoint.X
vX = vXmax - vXmin
vX2 = FormatNumber( vX*10, 2,0,-1,0)

Dim vY, vYmax, vYmin As Double
vYmax = odoc.ComponentDefinition.RangeBox.MaxPoint.Y
vYmin = odoc.ComponentDefinition.RangeBox.MinPoint.Y
vY = vYmax - vYmin
vY2 = FormatNumber( vY*10, 2,0,-1,0)

Dim vZ, vZmax, vZmin As Double

vZmax = odoc.ComponentDefinition.RangeBox.MaxPoint.Z
vZmin = odoc.ComponentDefinition.RangeBox.MinPoint.Z
vZ = vZmax - vZmin
vZ2 = FormatNumber( vZ*10, 2,0,-1,0)

iProperties.Value("Custom", "DIMENSÃO X") = vX2
iProperties.Value("Custom", "DIMENSÃO Y") = vY2
iProperties.Value("Custom", "DIMENSÃO Z") = vZ2 

 

Thanks for all.

Cristiano Oliveira
Developer Addins | Consultant CAD/PLM | CAD Manager
https://www.ConsultCAD.com/


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 4 of 5
Vladimir.Ananyev
in reply to: Crstiano

Hi Cristiano,

Thank you for the uploaded model, it helped to clarify the problem.

The range box is not always a tight fitting box. It's always axis aligned with the document axes system you're working in. The intent of the range box is to provide an easily calculated box that contains the object in question. This box can then be used as part of a pre-sorting algorithm to find or reject objects that cross a particular boundary. It's not intended to always tightly enclose an object. A reasonably tight fitting bounding box is computed for the part aligned with the part's coordinate system and cached in the part.

An occurrence bounding box takes this part box (not the part geometry), transforms it into the assembly space, and then fits a new box aligned with the assembly coordinates. If there is a non-orthogonal rotation between part and assembly space, the assembly box will be larger than the box in part space to fit around it. This is an optimization in order to avoid re-computing the part geometry bound in arbitrary assembly contexts.

The following picture demonstrates range boxes for the different occurrences of the same part model “10007.ipt”.

 Fig_2.png

Returning the optimal (aligned to principle geometry axis) or necessarily tight fitting bounds, is not a requirement for this API, but to return a reasonable bounding box that is only guaranteed to completely contain the geometry.  If you want an assembly’s tight fitting box you may calculate min and max points from existing surface facets.  This will always give tight bounding box in assembly and part context irrespective of shape.  Method directly works with the surface bodies and does not depend on work geometry visibility, sketches, etc.

Philippe Leefsma published the detailed blog article with the sample code that demonstrates this approach.  HIs code uses the client graphics to draw a range box that tightly encloses the part component.

http://adndevblog.typepad.com/manufacturing/2012/06/creating-accurate-rangebox-for-component.html

 

Here is the "correct" range box for the component “10007.ipt:6” in your model:

Fig_3.png

 

Having “correct” range boxes for every component you may combine them to get the overall assembly range box.

Not easy but should work.

Hope this helps.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 5
Crstiano
in reply to: Vladimir.Ananyev

Hi Vladimir,
I will try this and send to you my feedback.
Thank you at moment.
Cristiano Oliveira
Developer Addins | Consultant CAD/PLM | CAD Manager
https://www.ConsultCAD.com/


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

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

Post to forums  

Autodesk Design & Make Report