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: 

Parameter return values

1 REPLY 1
Reply
Message 1 of 2
NachitoMax
167 Views, 1 Reply

Parameter return values

Hey

 

i need to get for length formats from some parameters in code regardless of the input length type. Lets say i am entering 100 in as a string value to the parameter expression, the 4 return values i need back are:

A. 8' 4"

B. 8.3333 ft

C. 254 cm

D. 2540 mm

 

i can get the correct values from B, C & D but not 8. I can get it back in inches or decimal foot but not fraction. Is there an alternative way to convert into a fractional using inventor parameters? I need the same 4 results returned irrespective of the input i.e. if i entered 2540 mm, i would still get the same 4 results back.

 

im doing this in code btw

 

 

Thanks

Nacho

Automation & Design Engineer

Inventor Programmer (C#, VB.Net / iLogic)


EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


1 REPLY 1
Message 2 of 2
NachitoMax
in reply to: NachitoMax

Couldnt find an inventor method using vb.net, everything converts to decimal feet so i converted the input value to decimal feet then used this to convert to fractional feet

Private Function GetFractionFeet(ByVal DecimalLength As Double) As String

            Dim n64 As Integer = Math.Abs(CInt(Math.Round(DecimalLength * 12 * 64, 0)))
            Dim feet As Integer = n64 \ 64 \ 12
            Dim inches As Integer = n64 \ 64 - feet * 12
            Dim f64 As Integer = n64 Mod 64

            Dim fraction As String = ""
            If f64 > 0 Then
                Dim denom As Integer = 64
                Do While f64 Mod 2 = 0
                    f64 \= 2
                    denom \= 2
                Loop
                fraction = f64.ToString & "/" & denom.ToString & " "
            End If

            Dim sign As String = If(DecimalLength < 0, "-", "")
            Return String.Format("{0}{1}' {2}{3}""", sign, feet, inches, fraction)
        End Function

Nacho

Automation & Design Engineer

Inventor Programmer (C#, VB.Net / iLogic)


EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


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

Post to forums  

Technology Administrators


Autodesk Design & Make Report