cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cubic Yards

Cubic Yards

I work with concrete structures and use cubic yards not cubic feet. Trying to have this feature added in Inventor so that no special programming (iLogic) is required. I have used Inventor for many years yet this feature has not been added. 

1 Comment
clutsa
Collaborator

I ran into this a month ago now that we're exporting BOMs to an ERP system. Turns out you can set the unit of measure to "yd^3" but I did write this macro to help us go back and update old models. It's not commented and could really use cleaning up (the AddParameter sub doesn't need to be a sub here, but I had it from some other code so in the interest of saving time copy paste won out)

Sub Main()
	Dim doc = ThisDoc.Document
	volume = iProperties.Volume
	Dim oUOM
	Dim conv
	oUOM = doc.UnitsOfMeasure
	Dim strVolume
	Dim sLengthUnit
	sLengthUnit = oUOM.GetStringFromType(11266)
	'Logger.Debug("sLengthUnit = {0}", sLengthUnit)
	Dim sVolumeUnit
	sVolumeUnit = sLengthUnit & "^3"
	'Logger.Debug("sVolumeUnit = {0}", sVolumeUnit)
	roundInc = .01
	Dim UnitSpec As String = "yd^3"
	Dim strVolumeyd As String = oUOM.ConvertUnits(volume, sVolumeUnit, UnitSpec)
	Dim dblVolumeRounded As Double
	dblVolumeRounded = Ceil(Round(Val(strVolumeyd), 3) / roundInc) * roundInc
	'Logger.Debug("strVolumeyd = {0}", strVolumeyd)
	'Logger.Debug("dblVolumeRounded = {0}", dblVolumeRounded)
	'Logger.Debug("UnitSpec = {0}", UnitSpec)
	Try
		Parameter.Param("Volume_yd").Expression = dblVolumeRounded
	Catch ex As Exception
		'userParams.AddByValue("Volume_yd", dblVolumeRounded, UnitSpec)
		AddParameter("Volume_yd", dblVolumeRounded, UnitSpec)
		
	End Try
	
	Dim prtCompDef As PartComponentDefinition
	prtCompDef = doc.componentDefinition
	prtCompDef.BOMQuantity.SetBaseQuantity(kParameterBOMQuantity, Parameter.Param("Volume_yd"))
	
End Sub

Sub AddParameter(ParameterName As String, ParameterValue As Object, UnitSpec As Object, Optional oMultiValue As Object = Nothing)
	Dim doc As PartDocument = ThisDoc.Document
	Dim userParams As UserParameters = doc.ComponentDefinition.Parameters.UserParameters
	Dim param As UserParameter = userParams.AddByExpression(ParameterName, ParameterValue, UnitSpec)
	If Not oMultiValue Is Nothing Then
		MultiValue.List(ParameterName) = oMultiValue
	End If
End Sub

clutsa_0-1767616545835.png

 

 I understand the point you're looking for is not to need a macro so this doesn't really help you but if someone else finds your idea this might help them. I know this was much harder then I expected to get working. I figured I should have been able to simply set my Base Quantity in the Document Settings to my iProperty Volume and walk away but that isn't how it worked. 

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

Submit Idea