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.ExtentsHeight reporting wrong value

2 REPLIES 2
Reply
Message 1 of 3
icouture
768 Views, 2 Replies

Measure.ExtentsHeight reporting wrong value

Good morning all. I'm having a weird problem where my "stock" parts contain a rule to measure their length in the z-axis (used for HSS tubes, rods, angles etc.) so that I can create a liste of cuts to make for my guys on the workshop floor.

 

I'm having an issue with this one part where Measure.ExtentsHeight reports the wrong value. The true length of the part is 42 inches, the reported value by the iLogic code is 46.2 inches.

 

Can anything cause such a discrepancy?

 

Any pointers would be appreciated.

2 REPLIES 2
Message 2 of 3
xiaodong_liang
in reply to: icouture

Hi,

 

Thanks logging case through ADN where you provided the demo document.

 

If you switch off the visibility of the XY workplane, the value of Measure.ExtentsHeight is correct.  Measure.ExtentsHeight, Length and Width are actually the range box of the surface body. The extent of a workplane should not be covered in. I also checked SurfaceBody.RangeBox of Inventor API, it reports the correct values. So I doubt this is a problem with iLogic wrapped functions of Measure. 

 

The workaround is to get SurfaceBody.RangeBox and calculate the Height, Length and Width yourself. The below is a demo. It assumes there is only one surfacebody in this document and 3 parameters are available.

 

'calculate length of part in x axis and place this dimension in length custom parameter

'length = Measure.ExtentsHeight

'MsgBox( length)

 

doc = ThisDoc.Document

def = doc.ComponentDefinition

 

'assume the part has only one surface body

sb = def.SurfaceBodies(1)

'rangebox

minPt = sb.RangeBox.MinPoint

maxPt = sb.RangeBox.MaxPoint

 

 

'calculate the range along X-Y-Z

' the unit of core API uses centimeter, so needs to convert it to unit of document

oUOM = doc.UnitsOfMeasure

 

 

' X is extent length:

X = Math.abs(minPt.X - maxPt.X)

length =  oUOM.ConvertUnits(X,"cm" ,oUOM.LengthUnits )

 

' Y is extent width:

Y = Math.abs(minPt.Y - maxPt.Y)

width =  oUOM.ConvertUnits(Y,"cm" ,oUOM.LengthUnits )

 

' Z is extent height:

Z = Math.abs(minPt.Z - maxPt.Z)

height =  oUOM.ConvertUnits(Z,"cm" ,oUOM.LengthUnits )

 

 

 

 

 

 

 

Message 3 of 3
gazadder
in reply to: xiaodong_liang

Hi,

 

I came across this post when I was having issues with Measure.Extents giving incorrect values within an assembly. Range.Box may be the way to go but how can this be adapted for use with an assembly please?

 

Thanks

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

Post to forums  

Autodesk Design & Make Report