Jump to content

iLogic for Custom IProperties - how to retain trailing zeroes


DS-precast

Recommended Posts

Hello All

 

I have a simple iLogic Rule which converts the Mass (kg) iProperty into a Custom iProperty measured in tonnes, to 2 decimal places.

 

[color=#800080][b]iProperties[/b][/color][color=#000000].[/color][color=#800080][b]Value[/b][/color][color=#000000][b]([/b][/color][color=#008080]"[/color][color=#008080]Custom[/color][color=#008080]"[/color][color=#000000], [/color][color=#008080]"[/color][color=#008080]Weight (T)[/color][color=#008080]"[/color][color=#000000][b])[/b][/color][color=#000000][b]=[/b][/color][color=#800080][b]Round[/b][/color][color=#000000][b]([/b][/color][color=#800080][b]iProperties[/b][/color][color=#000000].[/color][color=#800080][b]Mass[/b][/color][color=#ff0000][b]/[/b][/color][color=#000000][b]1000[/b][/color][color=#000000],[/color][color=#000000][b]2[/b][/color][color=#000000][b])[/b][/color]

 

The problem I have is that the iProperty value seems to remove trailing zeroes, (ie. it will display '0.8' when I require it to display '0.80'.

 

Could anybody please indicate how to overcome this issue?

 

Many thanks

Edited by DS-precast
Link to comment
Share on other sites

I've got a similar iLogic / iProperty setup in my part and assembly templates, but I went at it a slightly different way. I bring iProperties.Mass in as a parameter, mark it for export, and then in the Custom Property Format window I specify how many decimal places I want, and there's checkboxes for leading & trailing zeroes.

 

Here's the code I use:

 

 
[color=#800080][b]InventorVb[/b][/color][color=#000000].[/color][color=#800080][b]DocumentUpdate[/b][/color][color=#000000][b]()[/b][/color]
[color=#800080][b]Parameter[/b][/color][color=#000000][b]([/b][/color][color=#008080]"[/color][color=#008080]partmass[/color][color=#008080]"[/color][color=#000000][b])[/b][/color][color=#000000][b]=[/b][/color][color=#800080][b]iProperties[/b][/color][color=#000000].[/color][color=#800080][b]Mass[/b][/color]
[color=#800080][b]InventorVb[/b][/color][color=#000000].[/color][color=#800080][b]DocumentUpdate[/b][/color][color=#000000][b]()[/b][/color]
[b]

[/b]

Link to comment
Share on other sites

Thanks for the reply Bishop.

 

I will try your solution and compare with the way I have done it, to see the merits or otherwise of each approach.

 

Since posting, I found another solution to the problem which I will post here to help others with the same or similar issues.

 

I found that using the vba FORMAT command, along with the ROUND command seems to produce the results I'm looking for.

 

My code now reads :

[color=#800080][b]iProperties[/b][/color][color=#000000].[/color][color=#800080][b]Value[/b][/color][color=#000000][b]([/b][/color][color=#008080]"[/color][color=#008080]Custom[/color][color=#008080]"[/color][color=#000000], [/color][color=#008080]"[/color][color=#008080]Weight (T)[/color][color=#008080]"[/color][color=#000000][b])[/b][/color][color=#000000] [/color][color=#000000][b]=[/b][/color][color=#000000] [/color][color=#800080][b]Format[/b][/color][color=#000000][b]([/b][/color][color=#800080][b]Round[/b][/color][color=#000000][b]([/b][/color][color=#800080][b]iProperties[/b][/color][color=#000000].[/color][color=#800080][b]Mass[/b][/color][color=#ff0000][b]/[/b][/color][color=#000000][b]1000[/b][/color][color=#000000],[/color][color=#000000][b]2[/b][/color][color=#000000][b])[/b][/color][color=#000000], [/color][color=#008080]"[/color][color=#008080]0.#0[/color][color=#008080]"[/color][color=#000000][b])[/b][/color]

:)

 

Thanks for the assistance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...