Need Help with iLogic code for description decimal place

Need Help with iLogic code for description decimal place

Anonymous
Not applicable
1,364 Views
10 Replies
Message 1 of 11

Need Help with iLogic code for description decimal place

Anonymous
Not applicable

So I have created a custom template for W-Beam creation and I've been able to get iLogic to generate the description for me, "almost", in the format I need, but the LENGTH is just showing up as a number, when it needs to be to (2) decimal places and show trailing zeros.

 

example:     BEAM, W6X9, (34.00" LONG)

what iLogic is giving me:    BEAM, W6X9, (34 LONG)

 

below is some info to help me figure out what I need to do. I've tryed rounding, but either I'm doing it wrong or it's not working for this example.

Any help would be great as I can't rool out this template until the description is fixed.

 

Chris

 

unknown.png

 

unknown.png

0 Likes
1,365 Views
10 Replies
Replies (10)
Message 2 of 11

BrandonBG
Collaborator
Collaborator

Check your Styles Editor. Are you stripping the units string "in" off your dimensions and adding " as text? You may need to add string back in your rule.

 

BrandonBG

Inventor 2015

 

styles.jpg

 

styles2.jpg

0 Likes
Message 3 of 11

jletcher
Advisor
Advisor

Can you post the code you have the pictures you posted are not there so I can't help if I can't see what you have..

0 Likes
Message 4 of 11

Anonymous
Not applicable

Yes, I will post the code in the morning.... it's driving me crazy. I've trying rounding, I've tried decimal place rules, I've tried linking the pram to a custom property and rounding that, I must be missing something....ahhhh.....

0 Likes
Message 5 of 11

jletcher
Advisor
Advisor

Ok I am sure we can help you out..

0 Likes
Message 6 of 11

Anonymous
Not applicable

iProperties.Value("Project""Description")="BEAM, " & Choose_Size & ", " & "(" & LENGTH & " LONG)"

 

 

0 Likes
Message 7 of 11

rjay75
Collaborator
Collaborator

To have something that will obey your document unit settings including the units they are set to. Not this will include the units.

 

uom = ThisDoc.Document.UnitsOfMeasure
p_len = uom.GetStringFromValue(Parameter.Param("LENGTH").Value, uom.LengthUnits)

iProperties.Value("Project", "Description")="BEAM, " & Choose_Size & ", " & "(" & p_len & " LONG)"

 

0 Likes
Message 8 of 11

Anonymous
Not applicable

I already emailed it to Chris, but here's code to do this. 

olength = Parameter.Param("Length")
olength.ExposedAsProperty = True
oFormat=olength.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kTwoDecimalPlacesPrecision
oFormat.Units="in"


iProperties.Value("Project", "Description") = "=<Length>"

 It's modified from code that Curtis_Waguespack posted in this thread. 

0 Likes
Message 9 of 11

Anonymous
Not applicable

The code Donovan provided successfully creates a length with 2 decimal places, but it strips out all the other info from the description. I tried combining his code with the original description code but it didn't seem to work together, so I'm still at square 1..??

 

I did confirm that if the dimension is 34.125 it displays the length with 3 decimlas, but for some reason it is not letting me keep trailing zeros..

0 Likes
Message 10 of 11

jletcher
Advisor
Advisor

This is the way I have mine set up.

 

 I don't use the Length Parameter in a sense.

 

Make a user parameter as "text" called L_1 or what ever you wish just not Length keep length for user input only

 

At the top of your ilogic code put this in

 

iLogicOption DoubleForEquals Off
L_1 = Format(LENGTH, "00.000")

you can change the "00.000" to "000.0000"  or "00.00" the zeros are how many places it will format.

 

 

then change your ilogic callout to

 

iProperties.Value("Project", "Description")="BEAM, " & Choose_Size & ", " & "(" & L_1 & " LONG)"

 

 

Also make sure your length Fx is set to export..

 

 

 

 

Message 11 of 11

jletcher
Advisor
Advisor

Oh if you don't want leading zeros make it ".000" so you only get trailing zeros I need leading also so that is why I have it that way..

0 Likes