Userparameter without trailing zeros

Userparameter without trailing zeros

richterBKSAC
Advocate Advocate
204 Views
3 Replies
Message 1 of 4

Userparameter without trailing zeros

richterBKSAC
Advocate
Advocate

Hi there,

 

I've found this post already https://forums.autodesk.com/t5/inventor-programming-ilogic/trim-parameter-from-trailing-zeros/m-p/10... and tried both code snippets marked as solution, but they don't work for me.

I'm using Inventor Professional 2023.4.

 

Thank you in advance

0 Likes
205 Views
3 Replies
Replies (3)
Message 2 of 4

bradeneuropeArthur
Mentor
Mentor

These codes work fine in Inventor 2022.

Can you upload your files so that we can check.

  • Are the units all mm units?
  • Are you using a .ipt file?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

The primary reasons why this is a complex task is that when we access the values of Parameter API objects, that represent values of units other than Text, Boolean, or unitless, is that the values are returned in 'database' units, instead of the units that the parameter is set to.  When the units are millimeters, we know that the value we get from the Parameter API object will be in centimeters (not millimeters), so we know that we can simply divide centimeters by 10 to get millimeters.  But there are tons of possible units that could be present in any given document, and we do not know how to convert all possible units values.

 

If I want to manually change how many trailing zeros I see in the parameters dialog for a specific parameter, I can do one of the following.

  • If I want more trailing zeros, I re-type the value with the needed number of trailing zeros, except leave the last digit a 1, instead of zero, then after accepting that, I change that last digit from a 1 to a zero.  The trailing zeros stay there.
  • If I want to completely eliminate any trailing zeros, I can simply re-type the value without any trailing zeros.
  • If there is an equation driving the value, then you generally do not have much control over the value, other than placing the equation within one of the few allowed parameter functions.

I had attempted this once before too, but gave up on it, because it just wasn't that important to me at the time.

Dim oDoc As Document = ThisDoc.Document
Dim oParams As Inventor.Parameters = Nothing
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Or
	oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
	oParams = oDoc.ComponentDefinition.Parameters
ElseIf oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
	oParams = oDoc.Parameters
Else
	Return
End If
If oParams.Count = 0 Then Return
Dim oParam As Inventor.Parameter
For Each oParam In oParams
	If oParam.Units = "Text" Or oParam.Units = "Boolean" Or oParam.Units = "ul" Then Continue For
	Dim oVal As Double = 0.0
	Try
		oVal = oParam.Value
		oVal = (oVal * 10) / 10
		oVal = Ceil(oVal)
		oParam.Value = oVal
	Catch
	End Try
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

richterBKSAC
Advocate
Advocate

Thank you for your reply and sorry about the late answer.

I'm using an .ipt and "mm".

 

So there is no way to fix it via some ilogic code? For my purposes I'm creating the parameters via ilogic but after that the user has to manually link+edit them to modelparameters. It would be nice to have them displayed like a manually created userparameter, but it's gladly no requirement for me.

 

Although I'm curious on why it worked in the 2022 version, like @bradeneuropeArthur mentioned, and not anymore in the 2023 version.

0 Likes