iLogic dimension accuracy

iLogic dimension accuracy

Anonymous
Not applicable
1,905 Views
9 Replies
Message 1 of 10

iLogic dimension accuracy

Anonymous
Not applicable

Hi.

 

I am automating part drawings in Inventor using iLogic.  I want the idw drawing to display dimensions to either zero Decimal places or one Decimal place depending on the dimensions value.  e.g. if the dimension is 124mm I want to see 124 (not 124.0).  If it is 124.1mm I want to see 124.1 (or if is it 124.1038976 I want to see 124.1).

 

Is there a bit of iLogic code that can do this?

 

Thanks,

 

Terry

Accepted solutions (3)
1,906 Views
9 Replies
Replies (9)
Message 2 of 10

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, try the following ilogic rule, I try to do what you need.

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet

For Each oDim As DrawingDimension In oSheet.DrawingDimensions
	If Round(oDim.ModelValue * 10, 1) -Round(oDim.ModelValue * 10, 0) = 0 Then 
		oDim.Precision = 0
	Else
		oDim.Precision = 1
	End If
Next

 I hope this helps with your work. Grettings!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 10

Anonymous
Not applicable
Accepted solution

Thanks a million Sergio.

 

That is exactly what I was after!!

 

Cheers,

 

Terry

 

 

0 Likes
Message 4 of 10

Anonymous
Not applicable

Hi.

 

My original question was answered (thank you Sergio) but I now have another similar and related question.

 

I am picking up the volume from the ipt iProperties and converting it to a custom iProperty for display in a text box on the idw drawing.  I have a bit of iLogic code to convert the volume to dm3 and ensure that three decimal places are displayed even when some/all of the D.P.s are zeros e.g. 12.000, 12.100, 12.110.

iProperties.Value("Custom", "Vol (dm3)") = (Format(Round(iProperties.Volume / 1000000, 3),".000"))

I now also need to ensure that the "integer part" of the decimal (left of the decimal point) displays as a number even if it is zero.

e.g. at the moment any number => 1 displays fine.  If the volume is 0.952 it displays as .952 and drops the zero.  Is there a bit of code anywhere that will ensure that the 0 is displayed in this circumstance?

 

Many thanks,

 

Terry

 

0 Likes
Message 5 of 10

Sergio.D.Suárez
Mentor
Mentor

Hi, I think you could use two paths for what you need.
If you define the property as a number, you do not need changes and the rule would look like this

Dim oValue As Double = (Format(Round(iProperties.Volume / 1000000, 3), ".000"))
iProperties.Value("Custom", "Vol (dm3)") = oValue

however, if you define the property as text you should use something like the following

Dim oValue As String = (Format(Round(iProperties.Volume / 1000000, 3), ".000"))
If oValue < 1 Then 
	iProperties.Value("Custom", "Vol (dm3)") = "0" & oValue
Else
	iProperties.Value("Custom", "Vol (dm3)") = oValue
End If

 I hope this helps with your problem. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 6 of 10

Anonymous
Not applicable
Accepted solution

Thanks very much Sergio

 

I will give it a try and let you know

0 Likes
Message 7 of 10

Anonymous
Not applicable

Hi Sergio.

 

The second option worked perfectly for what I wanted to do!!

 

Thanks again

 

Terry

0 Likes
Message 8 of 10

Formsprag
Advocate
Advocate

How would I apply this rule to specific dimensions in a rule?  Let's say I want dimensions 1-4 to be 1 decimal, 5-8 to be 2 decimals and 9-15 to be 3 decimals. Is that possible?

0 Likes
Message 9 of 10

ganeshholkar18
Explorer
Explorer

Hi,

 

I have used this iLogic rule to update dimension precision on drawing and it works fine.

 

Now what I need is I need this rule to be applied only for one view on drawing and remaining view on drawing should remain with zero "0" precision.

 

The view which should only be precise has name "UNDER". Is it possible to modify below iLogic rule for this requirement??

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet

For Each oDim As DrawingDimension In oSheet.DrawingDimensions
	If Round(oDim.ModelValue * 10, 1) -Round(oDim.ModelValue * 10, 0) = 0 Then 
		oDim.Precision = 0
	Else
		oDim.Precision = 1
	End If
Next

BR, Ganesh Holkar

0 Likes
Message 10 of 10

kirupakaranmech
Observer
Observer

Could please share alternate unit precision control i logic rule?

0 Likes