How can i get the ilogic rule to display "1 1/2"=1'0" in the drawing view, when I update a views dimensions per ilogic form?

How can i get the ilogic rule to display "1 1/2"=1'0" in the drawing view, when I update a views dimensions per ilogic form?

rkeeleyS5869
Explorer Explorer
113 Views
1 Reply
Message 1 of 2

How can i get the ilogic rule to display "1 1/2"=1'0" in the drawing view, when I update a views dimensions per ilogic form?

rkeeleyS5869
Explorer
Explorer

I'm trying to create an ilogic code that updates the size of the view based on the length x width and height of an object. I was able to successfully update the size of the drawing view, but since Inventor's ilogic scales per decimals, it shows up as an arbitrary fraction. Ex: .25 scale factor = 1/8 on the drawing sheet. I would test to say 1 1/2" = 1'-0". Can someone help with getting that to work?

 

0 Likes
114 Views
1 Reply
Reply (1)
Message 2 of 2

C_Haines_ENG
Collaborator
Collaborator

Its a simple solution, but I hate it:

 

EDIT: I missed the point of this question, can you reword your problem?

Sub Main

	Dim oValue As Double = InputBox("Enter Decimal Value", "Decimal To Fraction", "0.00")

	' THIS LIST CONTAINS ALL OF THE "FRACTION" VALUES YOU WANT TO CHECK FOR
	Dim oFractions As New List(Of Integer)
	oFractions.AddRange({2, 4, 8, 16})
	
	'CALLING FIND FRACTION FUNCTION
	Dim oFractionValue As String = FindFraction(oValue, oFractions)
	
	MsgBox(oFractionValue)

End Sub

Function FindFraction(oDecimal As Double, oFractions As List(Of Integer))
	
	'ROUND THE VALUE TO THE NEAREST MAX FRACTION VALUE
	Dim oValueRounded As Double = Round(oDecimal * oFractions.Max) / oFractions.Max
	
	'CHECK IF VALUE IS JUST A WHOLE NUMBER, IN WHICH THIS ISNT NEEDED
	If oValueRounded = Int(oValueRounded) Then Return oValueRounded
	
	'GET JUST THE DECIMALS FROM THE VALUE
	Dim oDecimals As Double = oValueRounded - Int(oValueRounded)
	
	'LOOP THROUGH EACH DENOMINIATOR 
	For Each oDenom As Integer In oFractions
		
		'GO THROUGH EACH VALUE IN THAT DENOMINATOR (CURSED)
		For i = 1 To oDenom - 1
			
			'IF THE DECIMAL VALUE MATCHES THE FRACTION, RETURN IT
			If oDecimals = i / oDenom Then Return Int(oValueRounded) & " " & i & "/" & oDenom & Chr(34)

		Next

	Next

End Function

 

 

0 Likes