Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need Help with iLogic code for description decimal place

10 REPLIES 10
Reply
Message 1 of 11
FritscheCAD
1007 Views, 10 Replies

Need Help with iLogic code for description decimal place

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

10 REPLIES 10
Message 2 of 11
BrandonBG
in reply to: FritscheCAD

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

Tags (2)
Message 3 of 11
jletcher
in reply to: FritscheCAD

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..

Message 4 of 11
FritscheCAD
in reply to: jletcher

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.....

Message 5 of 11
jletcher
in reply to: FritscheCAD

Ok I am sure we can help you out..

Message 6 of 11
FritscheCAD
in reply to: FritscheCAD

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

 

 

Message 7 of 11
rjay75
in reply to: FritscheCAD

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)"

 

Message 8 of 11
DonovanCox
in reply to: FritscheCAD

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. 

Message 9 of 11
FritscheCAD
in reply to: DonovanCox

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..

Message 10 of 11
jletcher
in reply to: FritscheCAD

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
in reply to: jletcher

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..

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

Post to forums  

Autodesk Design & Make Report