Code to measure length and width

Code to measure length and width

berry.lejeune
Advocate Advocate
118 Views
2 Replies
Message 1 of 3

Code to measure length and width

berry.lejeune
Advocate
Advocate

Hi all,

 

Don't even know if it's possible but I'll ask anyway

We've received a Revit model of a big building which is covered in stone plates. Now I need to get those dimensions of those plates for our manufacturer.But in stead of measuring each indivudial one, is it possible with a code to click on the surface and that it gives me the length and the width?

 

Thanks

0 Likes
119 Views
2 Replies
Replies (2)
Message 2 of 3

chris
Advisor
Advisor

@berry.lejeune I'm not sure exactly what the end result will be, but you can try this for the plates, this will give you the "geometrical dimensions of the parts in question.

 

in iLogic you can use this code to automatically have inventor tell you the geometric extents of a part in these 3 directions, (X, Y, Z)

 

Example:

1. I created a cube with 3 different dimensions in each axis (x=6", y=2", z=4")

2. I created 3 user-defined parameters: (Geo_Length, Geo_Height, Geo_Width)

3. Then I created this rule and run it

'Dimensions

Geo_Length = Measure.PreciseExtentsLength
Geo_Width = Measure.PreciseExtentsWidth
Geo_Height = Measure.PreciseExtentsHeight

4. Then check you parameters and you'll see the "extent" dimensions for the part

Message 3 of 3

Andrii_Humeniuk
Advisor
Advisor

Hi @berry.lejeune .
This iLogic code works as follows: you need to run it and click on the body surface, then you get a message about the surface size. Note that the software measurement in Inventor is in centimeters, but for exported documents from Revit for some reason the measurement is in foot. So you need to adjust this in line 4 and 5 by suppressing the unnecessary piece of code.
You can learn more about UnitsTypeEnum at the link.

Dim oInvApp As Inventor.Application = ThisApplication
Dim oCM As CommandManager = oInvApp.CommandManager
Dim oUOM As UnitsOfMeasure = oInvApp.ActiveDocument.UnitsOfMeasure
'Dim eLeng As UnitsTypeEnum = UnitsTypeEnum.kFootLengthUnits
Dim eLeng As UnitsTypeEnum = UnitsTypeEnum.kCentimeterLengthUnits

Do
	Dim oFace As Object
	oFace = oCM.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Face...")
	If oFace Is Nothing Then Exit Do
	Dim oBox As Box2d = oFace.Evaluator.ParamRangeRect
	Dim oSizes(1) As Double
	oSizes(0) = Round(oUOM.ConvertUnits(oBox.MaxPoint.X - oBox.MinPoint.X,
										eLeng, oUOM.LengthUnits), 3)
	oSizes(1) = Round(oUOM.ConvertUnits(oBox.MaxPoint.Y - oBox.MinPoint.Y,
										eLeng, oUOM.LengthUnits), 3)
	MessageBox.Show("Length - " & Abs(oSizes.Max) & vbLf &
					"Width - " & Abs(oSizes.Min), "Surface size:")
	Logger.Info("Length - " & Abs(oSizes.Max))
	Logger.Info("Width - " & Abs(oSizes.Min))
Loop

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes