iLogic Parameter value is wrong

iLogic Parameter value is wrong

Anonymous
Not applicable
1,274 Views
3 Replies
Message 1 of 4

iLogic Parameter value is wrong

Anonymous
Not applicable

Hi guys!

 

Can't use the parameter value in a formula because it sends the wrong value.

 

The value will show as the wrong one if it's alone but combined with the unit it's good.

 

There's something I must be missing.

 

Made a dummy assembly for you guys to have a look

 

Thanks

0 Likes
Accepted solutions (1)
1,275 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor
Accepted solution

Hi.

 

Grabbing parameters VALUES will always return the value in DATABASE UNITS.

 

As far as length goes, the value returned will be converted to cm. So you need to write in your code to convert it back.

 

Good luck,


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 4

HermJan.Otterman
Advisor
Advisor

so lenght is Always in cm,

angles are Always in Radians

Mass in Kilogram

Time in second

temperature in Kelvin...

 

 

ways to convert:

 

oUM.LengthUnits = UnitsTypeEnum.kInchLengthUnits

 

Dim slon222 As Double = oUM.ConvertUnits(oUM.GetValueFromExpression(oCD.Parameters.UserParameters.Item("LONGUEUR_MAITRE").expression, UnitsTypeEnum.kInchLengthUnits), "cm", "in")

 

Dim slon223 As Double = oUM.ConvertUnits((oCD.Parameters.UserParameters.Item("LONGUEUR_MAITRE").value), "cm", oUM.LengthUnits)

 

 

GetValueFromExpression   will Always give a value in cm.

 

specifying a unittype is only usefull if the expression has no unit.

 

 

 

 

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 4 of 4

pflaquerGCPB2
Observer
Observer

Late reply years later but figured this could help someone in the future

 

I was able to simply add a mathematical express at the end of my original value being returned and it did indeed work.  I needed my value in inches but was getting it in CM.  So I just added "/2.54" since 1In = 2.54CM.  

 

See my code for full context of how I used this within my own application, in which I needed to append material parameters to my filename after running a For Each loop where each file is saved as a separate DXF

 

Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
Dim THK As String = "_" & oCompDef.Parameters("d0").Value.ToString/2.54 & ".dxf"

 

0 Likes