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: 

Measure.ExtentsLength from a part to drawings

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
1586 Views, 7 Replies

Measure.ExtentsLength from a part to drawings

Is it possible to use the Measure.ExtentsLength in a drawing to get model dimensions?

 

What I am trying to do is get the overall dimensions of the model and place them in a sketch block in the drawings so our machinist can easily reference the stock material.  I have a solution for the other steps required but I can't figure out how to get the overall model dimensions.

 

Thanks for the support,

Steve

7 REPLIES 7
Message 2 of 8
mrattray
in reply to: Anonymous

Did you try the DrawingDimension.ModelValue property?

Even better you could try referencing an exported model parameter.

Mike (not Matt) Rattray

Message 3 of 8
Anonymous
in reply to: mrattray

Would the ModelValue property take into account extrusions stack one on the other to give the overall or would it give just the base distance? 

 

I think my best bet is to reference a model parameter.  I just have to figure out how to export the parameters I want.

 

I also  should have mentioned I would like to do this in iLogics and not VBA but if I have to it would not be the worst thing.

 

Thanks,

Steve

Message 4 of 8
mrattray
in reply to: Anonymous

Just make a user parameter then and make it's value the sum of your stacked extrusions.

Mike (not Matt) Rattray

Message 5 of 8
Anonymous
in reply to: mrattray

Did anybody find a solution for this? I'm trying to get the Extents Length of a model from the drawing view as well, for use in automatically setting the view scale.

Message 6 of 8
mrattray
in reply to: Anonymous

One option is to make the part a sheet metal part (if it's not already) and create a flat pattern. It won't hurt anything to make something that's not even thinking about being a sheet metal part one. Once you have a "flat pattern" (quotes because it might just be another not so flat view of the part) you'll have access to the flat pattern extents properties. This will give you two of the bounding box dimensions of the part that will automatically update whent he part changes. As far as the third dimension: if it's not really sheet metal then there's not much we can do about it besides my earlier suggestion.

Mike (not Matt) Rattray

Message 7 of 8
MechMachineMan
in reply to: mrattray

You can always just open the part invisible and get the rangebox of it and then create a list of Length, Width, Thickness, as below.

 

oSheet = ThisApplication.ActiveDocument.ActiveSheet

oDrawingView = oSheet.DrawingViews.Item(1)
oModel = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument

oDoc = ThisApplication.Documents.Open(oModel.FullFileName, False)

oCompDef = oDoc.ComponentDefinition
oBOX = oCompDef.RangeBox

oXDif = oUOM.ConvertUnits(Abs(oBOX.MaxPoint.X - oBOX.MinPoint.X), "cm", "in")
oYDif = oUOM.ConvertUnits(Abs(oBOX.MaxPoint.Y - oBOX.MinPoint.Y), "cm", "in")
oZDif = oUOM.ConvertUnits(Abs(oBOX.MaxPoint.Z - oBOX.MinPoint.Z), "cm", "in")

Dim oDIMS As New List(Of Double)
oDIMS.ADD(oXDIF)
oDIMS.ADD(oYDIF)
oDIMS.ADD(oZDIF)

oDIMS.Sort
oDIMS.Reverse

 

 

 

 

what i typically do is put the list into parameters within the part, so that I can easily format them as I wish. And have the sketched sym show those params via iProps.


--------------------------------------
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 8 of 8
Anonymous
in reply to: MechMachineMan

Hi All,

 

I'm trying to get the dimensions (length, breadth, height) of all the models referenced in an assembly. I'm planning to do this using either Inventor API or Apprentice API reading the BOM of the main assembly and opening each model and executing something similar to the below code (source from Justin's reply in this thread).

 

var compDef = assemblyDoc.ComponentDefinition;
var rangeBox = compDef.RangeBox;

 

MessageBox.Show("Unit is " + assemblyDoc.UnitsOfMeasure.GetStringFromType(assemblyDoc.UnitsOfMeasure.LengthUnits));

//to do: make changes based on units

var length = (rangeBox.MaxPoint.X - rangeBox.MinPoint.X) / 2.54;
var width = (rangeBox.MaxPoint.Y - rangeBox.MinPoint.Y) / 2.54;
var height = (rangeBox.MaxPoint.Z - rangeBox.MinPoint.Z) / 2.54;
MessageBox.Show(length + Environment.NewLine + width + Environment.NewLine + height);

 

 

But when I run the below ilogic rule on random models to check the output, for some models some dimensions differ by 1 or 2 inches

SyntaxEditor Code Snippet

MessageBox.Show(Measure.ExtentsLength, "Length")
MessageBox.Show(Measure.ExtentsWidth, "Width")
MessageBox.Show(Measure.ExtentsHeight, "Height")

Model1:

program (in)iLogic (in)
35.8334.8643055
32.81727.3675394
9696

 

Model 2:

program (in)iLogic (in)
18.750418.75
16.76816.7287
3.8282.9295

 

My questions are:

 

1. Why this difference in dimensional values? I checked the work features on these models, they were turned off.

2. Is there a better solution for my original problem? Get the dimensions (length, breadth, height) of all the models referenced in an assembly.

 

 

Thanks

Rekha.

Tags (2)

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

Post to forums  

Autodesk Design & Make Report