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
Did you try the DrawingDimension.ModelValue property?
Even better you could try referencing an exported model parameter.
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
Just make a user parameter then and make it's value the sum of your stacked extrusions.
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.
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.
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.
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.83 | 34.8643055 |
32.817 | 27.3675394 |
96 | 96 |
Model 2:
program (in) | iLogic (in) |
18.7504 | 18.75 |
16.768 | 16.7287 |
3.828 | 2.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.
Can't find what you're looking for? Ask the community or share your knowledge.